| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package tt; |
|
4
|
3
|
|
|
3
|
|
35110
|
use Module::Compile -base; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use strict; |
|
7
|
|
|
|
|
|
|
use warnings; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Template; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = "0.02"; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub default_tt_config { |
|
14
|
|
|
|
|
|
|
return ( |
|
15
|
|
|
|
|
|
|
INTERPOLATE => 0, |
|
16
|
|
|
|
|
|
|
EVAL_PERL => 1, |
|
17
|
|
|
|
|
|
|
INCLUDE_PATH => [ @INC ], |
|
18
|
|
|
|
|
|
|
LOAD_PERL => 1, |
|
19
|
|
|
|
|
|
|
DEBUG => "undef", |
|
20
|
|
|
|
|
|
|
); |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub default_tt_vars { |
|
24
|
|
|
|
|
|
|
my $class = shift; |
|
25
|
|
|
|
|
|
|
return ( |
|
26
|
|
|
|
|
|
|
filter_class => $class, |
|
27
|
|
|
|
|
|
|
'package' => undef, |
|
28
|
|
|
|
|
|
|
file => undef, |
|
29
|
|
|
|
|
|
|
from_line => undef, |
|
30
|
|
|
|
|
|
|
to_line => undef, |
|
31
|
|
|
|
|
|
|
); |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub pmc_compile { |
|
35
|
|
|
|
|
|
|
my ( $class, $source, $extra ) = @_; |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# try to make vars out of the use line |
|
38
|
|
|
|
|
|
|
my %use_opts = do { |
|
39
|
|
|
|
|
|
|
( my $vars = $extra->{use} ) =~ s/^\s*use\s+tt\s*//; |
|
40
|
|
|
|
|
|
|
eval "$vars"; |
|
41
|
|
|
|
|
|
|
}; |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
die "error evaluating vars on use line ($extra->{use}): $@" |
|
44
|
|
|
|
|
|
|
if $@; |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# try to remove keys that look like TT configuration |
|
48
|
|
|
|
|
|
|
my %config = ( |
|
49
|
|
|
|
|
|
|
$class->default_tt_config, |
|
50
|
|
|
|
|
|
|
map { $_ => delete $use_opts{$_} } grep /^[A-Z_]+$/, keys %use_opts, |
|
51
|
|
|
|
|
|
|
); |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my %vars = ( |
|
54
|
|
|
|
|
|
|
$class->default_tt_vars, |
|
55
|
|
|
|
|
|
|
%use_opts, |
|
56
|
|
|
|
|
|
|
); |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my $t = Template->new(\%config) || die Template->error; |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
$t->process( \$source, \%vars, \( my $out ) ) || die $t->error; |
|
61
|
|
|
|
|
|
|
$out || die $t->error; |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
return $out; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__PACKAGE__; |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__END__ |