| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::Rad::Plugin::TT; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = "0.2"; |
|
4
|
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
34836
|
use Template; |
|
|
1
|
|
|
|
|
43219
|
|
|
|
1
|
|
|
|
|
567
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub _default_obj { |
|
8
|
0
|
|
|
0
|
|
|
my $c = shift; |
|
9
|
|
|
|
|
|
|
|
|
10
|
0
|
|
0
|
|
|
|
Template->new( |
|
|
|
|
0
|
|
|
|
|
|
11
|
|
|
|
|
|
|
INCLUDE_PATH => $c->stash->{tt_include_path} || "." , |
|
12
|
|
|
|
|
|
|
TEMPLATE_EXTENSION => $c->{tt_extension} || ".tt2", |
|
13
|
|
|
|
|
|
|
); |
|
14
|
|
|
|
|
|
|
} |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub tt_config { |
|
17
|
0
|
|
|
0
|
1
|
|
my $c = shift; |
|
18
|
0
|
|
|
|
|
|
my $config = shift; |
|
19
|
|
|
|
|
|
|
|
|
20
|
0
|
0
|
|
|
|
|
$c->{'_tt_controler'} = delete $config->{CONTROLLER_VAR} if exists $config->{CONTROLLER_VAR}; |
|
21
|
0
|
|
|
|
|
|
$c->{'_tt_config'} = $config; |
|
22
|
0
|
|
|
|
|
|
$c->{'_tt_obj'} = Template->new(%$config); |
|
23
|
0
|
0
|
|
|
|
|
$c->{'_tt_extension'} = $config->{TEMPLATE_EXTENSION} if exists $config->{TEMPLATE_EXTENSION}; |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub _template_file { |
|
27
|
0
|
|
|
0
|
|
|
my $c = shift; |
|
28
|
|
|
|
|
|
|
|
|
29
|
0
|
0
|
|
|
|
|
if(exists $c->stash->{template}) { |
|
30
|
0
|
|
|
|
|
|
return $c->stash->{template}; |
|
31
|
|
|
|
|
|
|
}else { |
|
32
|
0
|
|
0
|
|
|
|
return $c->cmd . ($c->{'_tt_extension'} || ".tt2"); |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub process { |
|
37
|
0
|
|
|
0
|
1
|
|
my $c = shift; |
|
38
|
|
|
|
|
|
|
|
|
39
|
0
|
|
0
|
|
|
|
$c->{'_tt_obj'} ||= _default_obj($c); |
|
40
|
0
|
|
|
|
|
|
my $tt_file = _template_file($c); |
|
41
|
0
|
|
|
|
|
|
my $output; |
|
42
|
0
|
0
|
0
|
|
|
|
$c->{'_tt_obj'}->process($tt_file, { ($c->{'_tt_controler'} || "c") => $c, %{$c->stash} }, \$output) |
|
|
0
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|| die $c->{'_tt_obj'}->error(); |
|
44
|
0
|
|
|
|
|
|
$output; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub process_array { |
|
48
|
0
|
|
|
0
|
1
|
|
my $c = shift; |
|
49
|
0
|
|
|
|
|
|
my @vars = @{shift()}; |
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
51
|
0
|
|
0
|
|
|
|
$c->stash->{template_obj} ||= _default_obj($c); |
|
52
|
0
|
|
|
|
|
|
my $tt_file = _template_file($c); |
|
53
|
0
|
|
|
|
|
|
my $output; |
|
54
|
0
|
|
|
|
|
|
for my $vars(@vars){ |
|
55
|
0
|
|
|
|
|
|
my $output_part; |
|
56
|
0
|
0
|
|
|
|
|
$c->stash->{template_obj}->process($tt_file, {"c" => $c, %{$c->stash}, %$vars}, \$output_part) |
|
|
0
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|| die $c->stash->{template_obj}->error(); |
|
58
|
0
|
|
|
|
|
|
$output .= $output_part; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
0
|
|
|
|
|
|
$output; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub use_tt_post_process { |
|
64
|
0
|
|
|
0
|
1
|
|
my $c = shift; |
|
65
|
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
my $old_post_process = $c->{"_old_post_process_TT"} = $c->{"_functions"}->{post_process}; |
|
67
|
|
|
|
|
|
|
$c->{"_functions"} |
|
68
|
|
|
|
|
|
|
->{post_process} = sub { |
|
69
|
0
|
|
|
0
|
|
|
my $c = shift; |
|
70
|
0
|
0
|
|
|
|
|
if($c->cmd) { |
|
71
|
0
|
|
|
|
|
|
$c->output($c->process); |
|
72
|
|
|
|
|
|
|
} |
|
73
|
0
|
|
|
|
|
|
$old_post_process->($c); |
|
74
|
0
|
|
|
|
|
|
}; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub no_tt_post_process { |
|
78
|
0
|
|
|
0
|
1
|
|
my $c = shift; |
|
79
|
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
$c->{"_functions"}->{post_process} = $c->{"_old_post_process_TT"}; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
42; |