line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Text::Caml; |
2
|
1
|
|
|
1
|
|
533
|
use Mojo::Base 'Mojolicious::Plugin'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
570
|
use Text::Caml; |
|
1
|
|
|
|
|
2054
|
|
|
1
|
|
|
|
|
198
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub register { |
9
|
1
|
|
|
1
|
1
|
44
|
my ($self, $app, $args) = @_; |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
50
|
|
|
9
|
$args //= {}; |
12
|
1
|
|
|
|
|
10
|
my $caml = Text::Caml->new(%$args); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
$app->renderer->add_handler(caml => sub { |
15
|
2
|
|
|
2
|
|
34159
|
my ($renderer, $c, $output, $options) = @_; |
16
|
|
|
|
|
|
|
|
17
|
2
|
100
|
|
|
|
14
|
if ($options->{inline}) { |
|
|
50
|
|
|
|
|
|
18
|
1
|
|
|
|
|
4
|
my $inline_template = $options->{inline}; |
19
|
1
|
|
|
|
|
7
|
$$output = $caml->render($inline_template, $c->stash); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
elsif (my $template_name = $renderer->template_path($options)) { |
22
|
0
|
|
|
|
|
0
|
$caml->set_templates_path($renderer->paths->[0]); |
23
|
0
|
|
|
|
|
0
|
$$output = $caml->render_file($template_name, $c->stash); |
24
|
|
|
|
|
|
|
} else { |
25
|
1
|
|
|
|
|
1583
|
my $data_template = $renderer->get_data_template($options); |
26
|
1
|
50
|
|
|
|
36
|
$$output = $caml->render($data_template, $c->stash) if $data_template; |
27
|
|
|
|
|
|
|
} |
28
|
2
|
50
|
|
|
|
598
|
return $$output ? 1 : 0; |
29
|
1
|
|
|
|
|
25
|
}); |
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
24
|
return 1; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
1; |
35
|
|
|
|
|
|
|
__END__ |