line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
2752
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
88
|
|
2
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
150
|
|
3
|
|
|
|
|
|
|
package MojoX::Renderer::Alloy::Tmpl; |
4
|
|
|
|
|
|
|
BEGIN { |
5
|
2
|
|
|
2
|
|
74
|
$MojoX::Renderer::Alloy::Tmpl::AUTHORITY = 'cpan:AJGB'; |
6
|
|
|
|
|
|
|
} |
7
|
|
|
|
|
|
|
{ |
8
|
|
|
|
|
|
|
$MojoX::Renderer::Alloy::Tmpl::VERSION = '1.121150'; |
9
|
|
|
|
|
|
|
} |
10
|
|
|
|
|
|
|
#ABSTRACT: Template::Alloy's Text::Tmpl renderer |
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
14
|
use base 'MojoX::Renderer::Alloy'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
793
|
|
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
2
|
|
1053
|
use Template::Alloy qw( Tmpl ); |
|
2
|
|
|
|
|
28526
|
|
|
2
|
|
|
|
|
17
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
__PACKAGE__->attr('alloy'); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub _init { |
20
|
2
|
|
|
2
|
|
5
|
my $self = shift; |
21
|
|
|
|
|
|
|
|
22
|
2
|
|
|
|
|
15
|
my %config = ( |
23
|
|
|
|
|
|
|
START_TAG => '#[', |
24
|
|
|
|
|
|
|
END_TAG => ']#', |
25
|
|
|
|
|
|
|
$self->_default_config(@_), |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
2
|
|
|
|
|
19
|
my $alloy = Template::Alloy->new( |
29
|
|
|
|
|
|
|
%config, |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
2
|
50
|
|
|
|
73
|
$alloy->set_dir( $config{INCLUDE_PATH} ) |
33
|
|
|
|
|
|
|
if exists $config{INCLUDE_PATH}; |
34
|
|
|
|
|
|
|
|
35
|
2
|
|
|
|
|
27
|
$alloy->set_delimiters(@config{qw(START_TAG END_TAG)}); |
36
|
|
|
|
|
|
|
|
37
|
2
|
|
|
|
|
59
|
$self->alloy( $alloy ); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub _render { |
41
|
22
|
|
|
22
|
|
57
|
my ($self, $r, $c, $output, $options) = @_; |
42
|
|
|
|
|
|
|
|
43
|
22
|
|
|
|
|
47
|
my $inline = $options->{inline}; |
44
|
|
|
|
|
|
|
|
45
|
22
|
|
|
|
|
78
|
my $tname = $r->template_name($options); |
46
|
22
|
|
|
|
|
6694
|
my $path = $r->template_path($options); |
47
|
|
|
|
|
|
|
|
48
|
22
|
100
|
66
|
|
|
2041
|
return unless defined $inline || ( defined $path && defined $tname ); |
|
|
|
33
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
9
|
|
|
|
|
16
|
my $method; |
51
|
|
|
|
|
|
|
# inline |
52
|
9
|
50
|
|
|
|
254
|
if ( defined $inline ) { |
|
|
50
|
|
|
|
|
|
53
|
0
|
|
|
|
|
0
|
$method = 'parse_string'; |
54
|
0
|
|
|
|
|
0
|
$path = $inline; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
# regular file |
57
|
|
|
|
|
|
|
elsif ( -r $path ) { |
58
|
9
|
|
|
|
|
24
|
$method = 'parse_file'; |
59
|
|
|
|
|
|
|
} else { |
60
|
|
|
|
|
|
|
# inlined templates are not supported |
61
|
0
|
0
|
|
|
|
0
|
if ( $r->get_data_template($options, $tname) ) { |
62
|
0
|
|
|
|
|
0
|
$c->render_exception( |
63
|
|
|
|
|
|
|
"Inlined templates are not supported" |
64
|
|
|
|
|
|
|
); |
65
|
|
|
|
|
|
|
} else { |
66
|
0
|
|
|
|
|
0
|
$c->render_not_found( $tname ); |
67
|
|
|
|
|
|
|
}; |
68
|
0
|
|
|
|
|
0
|
return; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
9
|
|
|
|
|
246
|
my $alloy = $self->alloy; |
72
|
9
|
|
|
|
|
124
|
$alloy->set_values( |
73
|
|
|
|
|
|
|
$self->_template_vars( $c ) |
74
|
|
|
|
|
|
|
); |
75
|
|
|
|
|
|
|
|
76
|
9
|
|
|
|
|
417
|
eval { |
77
|
9
|
|
|
|
|
56
|
$$output = $alloy->$method( $path ); |
78
|
|
|
|
|
|
|
}; |
79
|
9
|
100
|
66
|
|
|
106435
|
if ( my $e = $alloy->error || $@ ) { |
80
|
2
|
|
|
|
|
38
|
chomp $e; |
81
|
2
|
|
|
|
|
222
|
$c->render_exception( $e ); |
82
|
|
|
|
|
|
|
|
83
|
2
|
|
|
|
|
118024
|
return; |
84
|
|
|
|
|
|
|
}; |
85
|
|
|
|
|
|
|
|
86
|
7
|
|
|
|
|
106
|
return 1; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
__END__ |