| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
5
|
|
|
5
|
|
31
|
use strict; |
|
|
5
|
|
|
|
|
8
|
|
|
|
5
|
|
|
|
|
157
|
|
|
2
|
5
|
|
|
5
|
|
26
|
use warnings; |
|
|
5
|
|
|
|
|
10
|
|
|
|
5
|
|
|
|
|
196
|
|
|
3
|
|
|
|
|
|
|
package MojoX::Renderer::Alloy; |
|
4
|
|
|
|
|
|
|
BEGIN { |
|
5
|
5
|
|
|
5
|
|
143
|
$MojoX::Renderer::Alloy::AUTHORITY = 'cpan:AJGB'; |
|
6
|
|
|
|
|
|
|
} |
|
7
|
|
|
|
|
|
|
{ |
|
8
|
|
|
|
|
|
|
$MojoX::Renderer::Alloy::VERSION = '1.121150'; |
|
9
|
|
|
|
|
|
|
} |
|
10
|
|
|
|
|
|
|
#ABSTRACT: Base class for Template::Alloy renderer |
|
11
|
|
|
|
|
|
|
|
|
12
|
5
|
|
|
5
|
|
25
|
use base 'Mojo::Base'; |
|
|
5
|
|
|
|
|
12
|
|
|
|
5
|
|
|
|
|
3134
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub build { |
|
17
|
8
|
|
|
8
|
1
|
61
|
my $self = shift->SUPER::new(@_); |
|
18
|
|
|
|
|
|
|
|
|
19
|
8
|
50
|
|
|
|
99
|
die "Abstract class cannot be built" |
|
20
|
|
|
|
|
|
|
if ref $self eq __PACKAGE__; |
|
21
|
|
|
|
|
|
|
|
|
22
|
8
|
|
|
|
|
49
|
$self->_init(@_); |
|
23
|
|
|
|
|
|
|
|
|
24
|
8
|
|
|
88
|
|
364
|
return sub { $self->_render(@_) }; |
|
|
88
|
|
|
|
|
1866631
|
|
|
25
|
|
|
|
|
|
|
}; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub _init { |
|
28
|
4
|
|
|
4
|
|
10
|
my $self = shift; |
|
29
|
|
|
|
|
|
|
|
|
30
|
4
|
|
|
|
|
29
|
$self->alloy( |
|
31
|
|
|
|
|
|
|
Template::Alloy->new( $self->_default_config(@_) ) |
|
32
|
|
|
|
|
|
|
); |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _default_config { |
|
36
|
8
|
|
|
8
|
|
27
|
my ($self, %args) = @_; |
|
37
|
|
|
|
|
|
|
|
|
38
|
8
|
|
33
|
|
|
45
|
my $app = delete $args{app} || delete $args{mojo}; |
|
39
|
|
|
|
|
|
|
|
|
40
|
8
|
|
33
|
|
|
259
|
my $compile_dir = defined $app && $app->home->rel_dir('tmp/ctpl'); |
|
41
|
8
|
|
33
|
|
|
948
|
my $inc_path = defined $app && $app->home->rel_dir('templates'); |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
return ( |
|
44
|
|
|
|
|
|
|
( |
|
45
|
8
|
50
|
|
|
|
128
|
$inc_path ? |
|
46
|
|
|
|
|
|
|
( |
|
47
|
|
|
|
|
|
|
INCLUDE_PATH => $inc_path |
|
48
|
|
|
|
|
|
|
) : () |
|
49
|
|
|
|
|
|
|
), |
|
50
|
|
|
|
|
|
|
COMPILE_EXT => '.ct', |
|
51
|
|
|
|
|
|
|
COMPILE_DIR => ( $compile_dir || File::Spec->tmpdir ), |
|
52
|
|
|
|
|
|
|
UNICODE => 1, |
|
53
|
|
|
|
|
|
|
ENCODING => 'utf-8', |
|
54
|
|
|
|
|
|
|
CACHE_SIZE => 128, |
|
55
|
|
|
|
|
|
|
RELATIVE => 1, |
|
56
|
|
|
|
|
|
|
ABSOLUTE => 1, |
|
57
|
8
|
50
|
33
|
|
|
344
|
%{ $args{template_options} || {} }, |
|
58
|
|
|
|
|
|
|
); |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub _get_input { |
|
62
|
44
|
|
|
44
|
|
165
|
my ( $self, $r, $c, $options ) = @_; |
|
63
|
|
|
|
|
|
|
|
|
64
|
44
|
|
|
|
|
99
|
my $inline = $options->{inline}; |
|
65
|
|
|
|
|
|
|
|
|
66
|
44
|
|
|
|
|
148
|
my $tname = $r->template_name($options); |
|
67
|
44
|
|
|
|
|
713
|
my $path = $r->template_path($options); |
|
68
|
|
|
|
|
|
|
|
|
69
|
44
|
50
|
|
|
|
4414
|
$path = \$inline if defined $inline; |
|
70
|
|
|
|
|
|
|
|
|
71
|
44
|
100
|
66
|
|
|
337
|
return unless defined $path && defined $tname; |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
return ref $path ? $path # inline |
|
74
|
|
|
|
|
|
|
: -r $path ? |
|
75
|
|
|
|
|
|
|
$path # regular file |
|
76
|
|
|
|
|
|
|
: |
|
77
|
18
|
50
|
|
|
|
611
|
do { # inlined templates are not supported |
|
|
|
50
|
|
|
|
|
|
|
78
|
0
|
0
|
|
|
|
0
|
if ( $r->get_data_template($options, $tname) ) { |
|
79
|
0
|
|
|
|
|
0
|
$c->render_exception( |
|
80
|
|
|
|
|
|
|
"Inlined templates are not supported" |
|
81
|
|
|
|
|
|
|
); |
|
82
|
|
|
|
|
|
|
} else { |
|
83
|
0
|
|
|
|
|
0
|
$c->render_not_found( $tname ); |
|
84
|
|
|
|
|
|
|
} |
|
85
|
0
|
|
|
|
|
0
|
return; |
|
86
|
|
|
|
|
|
|
}; |
|
87
|
|
|
|
|
|
|
}; |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub _template_vars { |
|
90
|
36
|
|
|
36
|
|
90
|
my ($self, $c) = @_; |
|
91
|
|
|
|
|
|
|
|
|
92
|
36
|
|
|
|
|
374
|
my $helper = MojoX::Renderer::Alloy::Helper->new(ctx => $c); |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# allows to overwrite "h" |
|
95
|
|
|
|
|
|
|
return { |
|
96
|
36
|
|
|
|
|
148
|
h => $helper, |
|
97
|
36
|
|
|
|
|
373
|
%{ $c->stash }, |
|
98
|
|
|
|
|
|
|
c => $c, |
|
99
|
|
|
|
|
|
|
}, |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
# stolen from MojoX::Renderer::TT |
|
103
|
|
|
|
|
|
|
package |
|
104
|
|
|
|
|
|
|
MojoX::Renderer::Alloy::Helper; |
|
105
|
|
|
|
|
|
|
|
|
106
|
5
|
|
|
5
|
|
29
|
use strict; |
|
|
5
|
|
|
|
|
10
|
|
|
|
5
|
|
|
|
|
155
|
|
|
107
|
5
|
|
|
5
|
|
22
|
use warnings; |
|
|
5
|
|
|
|
|
11
|
|
|
|
5
|
|
|
|
|
164
|
|
|
108
|
|
|
|
|
|
|
|
|
109
|
5
|
|
|
5
|
|
22
|
use base 'Mojo::Base'; |
|
|
5
|
|
|
|
|
10
|
|
|
|
5
|
|
|
|
|
1595
|
|
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
our $AUTOLOAD; |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
__PACKAGE__->attr('ctx'); |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub AUTOLOAD { |
|
116
|
8
|
|
|
8
|
|
9921
|
my $self = shift; |
|
117
|
|
|
|
|
|
|
|
|
118
|
8
|
|
|
|
|
28
|
my $method = $AUTOLOAD; |
|
119
|
|
|
|
|
|
|
|
|
120
|
8
|
50
|
|
|
|
65
|
return if $method =~ /^[A-Z]+?$/; |
|
121
|
8
|
50
|
|
|
|
40
|
return if $method =~ /^_/; |
|
122
|
8
|
50
|
|
|
|
37
|
return if $method =~ /(?:\:*?)DESTROY$/; |
|
123
|
|
|
|
|
|
|
|
|
124
|
8
|
|
|
|
|
58
|
$method = (split '::' => $method)[-1]; |
|
125
|
|
|
|
|
|
|
|
|
126
|
8
|
100
|
|
|
|
246
|
die qq/Unknown helper: $method/ unless $self->ctx->app->renderer->helpers->{$method}; |
|
127
|
|
|
|
|
|
|
|
|
128
|
4
|
|
|
|
|
445
|
return $self->ctx->$method(@_); |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
1; |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
__END__ |