line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Template::Preprocessor::TTML; |
2
|
|
|
|
|
|
|
$Template::Preprocessor::TTML::VERSION = '0.0105'; |
3
|
1
|
|
|
1
|
|
68510
|
use warnings; |
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
33
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
4
|
use base 'Template::Preprocessor::TTML::Base'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
489
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
528
|
use Template; |
|
1
|
|
|
|
|
22048
|
|
|
1
|
|
|
|
|
34
|
|
9
|
1
|
|
|
1
|
|
501
|
use Template::Preprocessor::TTML::CmdLineProc; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
7
|
|
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
|
|
|
|
|
27
|
my %args = (@_); |
24
|
10
|
|
|
|
|
19
|
$self->argv( [ @{ $args{'argv'} } ] ); |
|
10
|
|
|
|
|
47
|
|
25
|
|
|
|
|
|
|
|
26
|
10
|
|
|
|
|
151
|
return 0; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub _calc_opts |
31
|
|
|
|
|
|
|
{ |
32
|
10
|
|
|
10
|
|
20
|
my $self = shift; |
33
|
10
|
|
|
|
|
32
|
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
|
|
276
|
my $self = shift; |
41
|
8
|
100
|
|
|
|
17
|
if ( $self->opts()->output_to_stdout() ) |
42
|
|
|
|
|
|
|
{ |
43
|
7
|
|
|
|
|
130
|
return (); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
else |
46
|
|
|
|
|
|
|
{ |
47
|
1
|
|
|
|
|
19
|
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
|
|
50
|
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
|
|
27
|
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
|
|
21
|
my $self = shift; |
93
|
|
|
|
|
|
|
|
94
|
1
|
|
|
|
|
4
|
print $self->_get_help_text(); |
95
|
|
|
|
|
|
|
|
96
|
1
|
|
|
|
|
10
|
return 0; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub run |
100
|
|
|
|
|
|
|
{ |
101
|
10
|
|
|
10
|
1
|
18792
|
my $self = shift; |
102
|
10
|
|
|
|
|
37
|
$self->_calc_opts(); |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
return $self->can( |
105
|
10
|
|
|
|
|
216
|
$self->_get_mode_callbacks()->{ $self->opts()->run_mode() } )->($self); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub _mode_regular |
109
|
|
|
|
|
|
|
{ |
110
|
8
|
|
|
8
|
|
149
|
my $self = shift; |
111
|
|
|
|
|
|
|
my $config = { |
112
|
8
|
|
|
|
|
16
|
INCLUDE_PATH => [ @{ $self->opts()->include_path() }, ".", ], |
|
8
|
|
|
|
|
17
|
|
113
|
|
|
|
|
|
|
EVAL_PERL => 1, |
114
|
|
|
|
|
|
|
PRE_PROCESS => $self->opts()->include_files(), |
115
|
|
|
|
|
|
|
}; |
116
|
8
|
|
|
|
|
288
|
my $template = Template->new($config); |
117
|
|
|
|
|
|
|
|
118
|
8
|
100
|
|
|
|
27368
|
if ( |
119
|
|
|
|
|
|
|
!$template->process( |
120
|
|
|
|
|
|
|
$self->opts()->input_filename(), $self->opts()->defines(), |
121
|
|
|
|
|
|
|
$self->_get_output(), |
122
|
|
|
|
|
|
|
) |
123
|
|
|
|
|
|
|
) |
124
|
|
|
|
|
|
|
{ |
125
|
1
|
|
|
|
|
1277
|
die $template->error(); |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
1; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
__END__ |