line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Text::Caml; |
2
|
2
|
|
|
2
|
|
1151
|
use v5.10.0; |
|
2
|
|
|
|
|
12
|
|
3
|
2
|
|
|
2
|
|
9
|
use Mojo::Base 'Mojolicious::Plugin'; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
13
|
|
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
1502
|
use Text::Caml; |
|
2
|
|
|
|
|
4779
|
|
|
2
|
|
|
|
|
417
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.08'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub register { |
10
|
2
|
|
|
2
|
1
|
77
|
my ( $self, $app, $args ) = @_; |
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
|
|
8
|
my $caml = Text::Caml->new(%$args); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
$app->renderer->add_handler( |
15
|
|
|
|
|
|
|
caml => sub { |
16
|
4
|
|
|
4
|
|
49100
|
my ( $renderer, $c, $output, $options ) = @_; |
17
|
|
|
|
|
|
|
|
18
|
4
|
100
|
|
|
|
32
|
if ( $options->{inline} ) { |
|
|
100
|
|
|
|
|
|
19
|
1
|
|
|
|
|
3
|
my $inline_template = $options->{inline}; |
20
|
1
|
|
|
|
|
5
|
$$output = $caml->render( $inline_template, $c->stash ); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
elsif ( my $template_name = $renderer->template_path($options) ) { |
23
|
1
|
|
|
|
|
84
|
$caml->set_templates_path( $renderer->paths->[0] ); |
24
|
1
|
|
|
|
|
12
|
$$output = $caml->render_file( $template_name, $c->stash ); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
else { |
27
|
2
|
|
100
|
|
|
2591
|
my $data_template = $renderer->get_data_template($options) // ''; |
28
|
2
|
|
|
|
|
62
|
$$output = $caml->render( $data_template, $c->stash ); |
29
|
|
|
|
|
|
|
} |
30
|
4
|
|
|
|
|
1689
|
return !!$$output; |
31
|
|
|
|
|
|
|
} |
32
|
2
|
|
|
|
|
42
|
); |
33
|
|
|
|
|
|
|
|
34
|
2
|
|
|
|
|
61
|
return 1; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |
38
|
|
|
|
|
|
|
__END__ |