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