line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Template::Preprocessor::TTML; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
42272
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
62
|
|
4
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
49
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
9
|
use base 'Template::Preprocessor::TTML::Base'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
1200
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
1604
|
use Template; |
|
2
|
|
|
|
|
2834247
|
|
|
2
|
|
|
|
|
94
|
|
9
|
2
|
|
|
2
|
|
1456
|
use Template::Preprocessor::TTML::CmdLineProc; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
13
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw( |
12
|
|
|
|
|
|
|
argv |
13
|
|
|
|
|
|
|
opts |
14
|
|
|
|
|
|
|
)); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION = '0.0103'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub initialize |
21
|
|
|
|
|
|
|
{ |
22
|
10
|
|
|
10
|
1
|
17
|
my $self = shift; |
23
|
10
|
|
|
|
|
24
|
my %args = (@_); |
24
|
10
|
|
|
|
|
17
|
$self->argv([@{$args{'argv'}}]); |
|
10
|
|
|
|
|
47
|
|
25
|
|
|
|
|
|
|
|
26
|
10
|
|
|
|
|
136
|
return 0; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub _calc_opts |
31
|
|
|
|
|
|
|
{ |
32
|
10
|
|
|
10
|
|
13
|
my $self = shift; |
33
|
10
|
|
|
|
|
32
|
my $cmd_line = Template::Preprocessor::TTML::CmdLineProc->new(argv => $self->argv()); |
34
|
10
|
|
|
|
|
35
|
$self->opts($cmd_line->get_result()); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub _get_output |
38
|
|
|
|
|
|
|
{ |
39
|
8
|
|
|
8
|
|
251
|
my $self = shift; |
40
|
8
|
100
|
|
|
|
24
|
if ($self->opts()->output_to_stdout()) |
41
|
|
|
|
|
|
|
{ |
42
|
7
|
|
|
|
|
134
|
return (); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
else |
45
|
|
|
|
|
|
|
{ |
46
|
1
|
|
|
|
|
16
|
return ($self->opts()->output_filename()); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub _get_mode_callbacks |
51
|
|
|
|
|
|
|
{ |
52
|
|
|
|
|
|
|
return { |
53
|
10
|
|
|
10
|
|
49
|
'regular' => "_mode_regular", |
54
|
|
|
|
|
|
|
'help' => "_mode_help", |
55
|
|
|
|
|
|
|
'version' => "_mode_version", |
56
|
|
|
|
|
|
|
}; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub _mode_version |
60
|
|
|
|
|
|
|
{ |
61
|
1
|
|
|
1
|
|
42
|
print <<"EOF"; |
62
|
|
|
|
|
|
|
This is TTML version $VERSION |
63
|
|
|
|
|
|
|
TTML is a Command Line Preprocessor based on the Template Toolkit |
64
|
|
|
|
|
|
|
(http://www.template-toolkit.org/) |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
More information about TTML can be found at: |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
http://search.cpan.org/dist/Template-Preprocessor-TTML/ |
69
|
|
|
|
|
|
|
EOF |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub _get_help_text |
73
|
|
|
|
|
|
|
{ |
74
|
1
|
|
|
1
|
|
25
|
return <<"EOF"; |
75
|
|
|
|
|
|
|
ttml - A Template Toolkit Based Preprocessor |
76
|
|
|
|
|
|
|
Usage: ttml [-o OUTPUTFILE] [OPTIONS] INPUTFILE |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Options: |
79
|
|
|
|
|
|
|
-o OUTPUTFILE - Output to file instead of stdout. |
80
|
|
|
|
|
|
|
-I PATH, --include=PATH - Append PATH to the include path |
81
|
|
|
|
|
|
|
-DVAR=VALUE, --define=VAR=VALUE - Define a pre-defined variable. |
82
|
|
|
|
|
|
|
--includefile=FILE - Include FILE at the top. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
-V, --version - display the version number. |
85
|
|
|
|
|
|
|
-h, --help - display this help listing. |
86
|
|
|
|
|
|
|
EOF |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub _mode_help |
90
|
|
|
|
|
|
|
{ |
91
|
1
|
|
|
1
|
|
18
|
my $self = shift; |
92
|
|
|
|
|
|
|
|
93
|
1
|
|
|
|
|
4
|
print $self->_get_help_text(); |
94
|
|
|
|
|
|
|
|
95
|
1
|
|
|
|
|
5
|
return 0; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub run |
99
|
|
|
|
|
|
|
{ |
100
|
10
|
|
|
10
|
1
|
1581
|
my $self = shift; |
101
|
10
|
|
|
|
|
26
|
$self->_calc_opts(); |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
return $self->can( |
104
|
10
|
|
|
|
|
172
|
$self->_get_mode_callbacks()->{$self->opts()->run_mode()} |
105
|
|
|
|
|
|
|
)->($self); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub _mode_regular |
109
|
|
|
|
|
|
|
{ |
110
|
8
|
|
|
8
|
|
126
|
my $self = shift; |
111
|
|
|
|
|
|
|
my $config = |
112
|
|
|
|
|
|
|
{ |
113
|
8
|
|
|
|
|
11
|
INCLUDE_PATH => [ @{$self->opts()->include_path()}, ".", ], |
|
8
|
|
|
|
|
18
|
|
114
|
|
|
|
|
|
|
EVAL_PERL => 1, |
115
|
|
|
|
|
|
|
PRE_PROCESS => $self->opts()->include_files(), |
116
|
|
|
|
|
|
|
}; |
117
|
8
|
|
|
|
|
285
|
my $template = Template->new($config); |
118
|
|
|
|
|
|
|
|
119
|
8
|
100
|
|
|
|
2234425
|
if (! |
120
|
|
|
|
|
|
|
$template->process( |
121
|
|
|
|
|
|
|
$self->opts()->input_filename(), |
122
|
|
|
|
|
|
|
$self->opts()->defines(), |
123
|
|
|
|
|
|
|
$self->_get_output(), |
124
|
|
|
|
|
|
|
) |
125
|
|
|
|
|
|
|
) |
126
|
|
|
|
|
|
|
{ |
127
|
1
|
|
|
|
|
1175
|
die $template->error(); |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
1; |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
__END__ |