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