line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package Mojolicious::Plugin::AlloyRenderer; |
3
|
|
|
|
|
|
|
BEGIN { |
4
|
5
|
|
|
5
|
|
9068
|
$Mojolicious::Plugin::AlloyRenderer::AUTHORITY = 'cpan:AJGB'; |
5
|
|
|
|
|
|
|
} |
6
|
|
|
|
|
|
|
{ |
7
|
|
|
|
|
|
|
$Mojolicious::Plugin::AlloyRenderer::VERSION = '1.121150'; |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
#ABSTRACT: Template::Alloy renderer plugin |
10
|
|
|
|
|
|
|
|
11
|
5
|
|
|
5
|
|
41
|
use strict; |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
216
|
|
12
|
5
|
|
|
5
|
|
29
|
use warnings; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
163
|
|
13
|
|
|
|
|
|
|
|
14
|
5
|
|
|
5
|
|
27
|
use base 'Mojolicious::Plugin'; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
559
|
|
15
|
|
|
|
|
|
|
|
16
|
5
|
|
|
5
|
|
33
|
use Mojo::Loader; |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
41
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my %syn2ext = ( |
21
|
|
|
|
|
|
|
'TT' => 'tt', |
22
|
|
|
|
|
|
|
'Velocity' => 'vtl', |
23
|
|
|
|
|
|
|
'Tmpl' => 'tmpl', |
24
|
|
|
|
|
|
|
'HTE' => 'hte', |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub register { |
28
|
5
|
|
|
5
|
1
|
253
|
my ($self, $app, $args) = @_; |
29
|
5
|
|
50
|
|
|
28
|
$args ||= {}; |
30
|
|
|
|
|
|
|
|
31
|
5
|
|
|
|
|
9
|
my @setup; |
32
|
5
|
50
|
|
|
|
27
|
if ( my $s = delete $args->{syntax} ) { |
33
|
|
|
|
|
|
|
# default extensions |
34
|
|
|
|
|
|
|
# syntax => [qw( TT HTE )] |
35
|
5
|
50
|
|
|
|
36
|
if ( ref $s eq 'ARRAY' ) { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
36
|
|
|
|
|
|
|
push @setup, [ $_ => $syn2ext{$_} ] |
37
|
0
|
|
|
|
|
0
|
for @$s; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
# custom extensions |
40
|
|
|
|
|
|
|
# syntax => {(TT => 'tt3', HTE => 'ht' )} |
41
|
|
|
|
|
|
|
elsif ( ref $s eq 'HASH' ) { |
42
|
0
|
|
|
|
|
0
|
while (my($k,$v) = each %$s) { |
43
|
0
|
|
|
|
|
0
|
push @setup, [ $k => $v ]; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
# single syntax with default extension |
47
|
|
|
|
|
|
|
# syntax => 'HTE' |
48
|
|
|
|
|
|
|
elsif ( ! ref $s ) { |
49
|
5
|
100
|
|
|
|
13
|
if ( $s eq ':all' ) { |
50
|
|
|
|
|
|
|
push @setup, [ $_ => $syn2ext{$_} ] |
51
|
1
|
|
|
|
|
14
|
for sort keys %syn2ext; |
52
|
|
|
|
|
|
|
} else { |
53
|
4
|
|
|
|
|
17
|
push @setup, [ $s => $syn2ext{$s} ]; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
else { |
57
|
0
|
|
|
|
|
0
|
die "Unrecognised configuration for 'alloy_renderer' plugin: $s\n"; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
# defaults to TT |
60
|
|
|
|
|
|
|
} else { |
61
|
0
|
|
|
|
|
0
|
push @setup, [ TT => $syn2ext{TT} ]; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
5
|
|
|
|
|
26
|
my $loader = Mojo::Loader->new; |
65
|
|
|
|
|
|
|
|
66
|
5
|
|
|
|
|
36
|
for my $syn ( @setup ) { |
67
|
8
|
|
|
|
|
97
|
my ($module, $extension) = @$syn; |
68
|
8
|
|
|
|
|
20
|
my $class = "MojoX::Renderer::Alloy::$module"; |
69
|
|
|
|
|
|
|
|
70
|
8
|
|
|
|
|
27
|
$loader->load( $class ); |
71
|
|
|
|
|
|
|
|
72
|
8
|
|
|
|
|
253
|
my $alloy = $class->build(%$args, app => $app); |
73
|
|
|
|
|
|
|
|
74
|
8
|
|
|
|
|
202
|
$app->renderer->add_handler($extension => $alloy); |
75
|
8
|
|
|
|
|
565
|
$app->renderer->default_handler($extension); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
__END__ |