| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#============================================================= -*-perl-*- |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
# Template::Config |
|
4
|
|
|
|
|
|
|
# |
|
5
|
|
|
|
|
|
|
# DESCRIPTION |
|
6
|
|
|
|
|
|
|
# Template Toolkit configuration module. |
|
7
|
|
|
|
|
|
|
# |
|
8
|
|
|
|
|
|
|
# AUTHOR |
|
9
|
|
|
|
|
|
|
# Andy Wardley |
|
10
|
|
|
|
|
|
|
# |
|
11
|
|
|
|
|
|
|
# COPYRIGHT |
|
12
|
|
|
|
|
|
|
# Copyright (C) 1996-2007 Andy Wardley. All Rights Reserved. |
|
13
|
|
|
|
|
|
|
# |
|
14
|
|
|
|
|
|
|
# This module is free software; you can redistribute it and/or |
|
15
|
|
|
|
|
|
|
# modify it under the same terms as Perl itself. |
|
16
|
|
|
|
|
|
|
# |
|
17
|
|
|
|
|
|
|
#======================================================================== |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
package Template::Config; |
|
20
|
|
|
|
|
|
|
|
|
21
|
92
|
|
|
92
|
|
284
|
use strict; |
|
|
92
|
|
|
|
|
83
|
|
|
|
92
|
|
|
|
|
2806
|
|
|
22
|
92
|
|
|
92
|
|
924
|
use warnings; |
|
|
92
|
|
|
|
|
701
|
|
|
|
92
|
|
|
|
|
3027
|
|
|
23
|
92
|
|
|
92
|
|
271
|
use base 'Template::Base'; |
|
|
92
|
|
|
|
|
760
|
|
|
|
92
|
|
|
|
|
6544
|
|
|
24
|
92
|
|
|
|
|
88671
|
use vars qw( $VERSION $DEBUG $ERROR $INSTDIR |
|
25
|
|
|
|
|
|
|
$PARSER $PROVIDER $PLUGINS $FILTERS $ITERATOR |
|
26
|
|
|
|
|
|
|
$LATEX_PATH $PDFLATEX_PATH $DVIPS_PATH |
|
27
|
92
|
|
|
92
|
|
1048
|
$STASH $SERVICE $CONTEXT $CONSTANTS @PRELOAD ); |
|
|
92
|
|
|
|
|
716
|
|
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
$VERSION = 2.75; |
|
30
|
|
|
|
|
|
|
$DEBUG = 0 unless defined $DEBUG; |
|
31
|
|
|
|
|
|
|
$ERROR = ''; |
|
32
|
|
|
|
|
|
|
$CONTEXT = 'Template::Context'; |
|
33
|
|
|
|
|
|
|
$FILTERS = 'Template::Filters'; |
|
34
|
|
|
|
|
|
|
$ITERATOR = 'Template::Iterator'; |
|
35
|
|
|
|
|
|
|
$PARSER = 'Template::Parser'; |
|
36
|
|
|
|
|
|
|
$PLUGINS = 'Template::Plugins'; |
|
37
|
|
|
|
|
|
|
$PROVIDER = 'Template::Provider'; |
|
38
|
|
|
|
|
|
|
$SERVICE = 'Template::Service'; |
|
39
|
|
|
|
|
|
|
$STASH = 'Template::Stash::XS'; |
|
40
|
|
|
|
|
|
|
$CONSTANTS = 'Template::Namespace::Constants'; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
@PRELOAD = ( $CONTEXT, $FILTERS, $ITERATOR, $PARSER, |
|
43
|
|
|
|
|
|
|
$PLUGINS, $PROVIDER, $SERVICE, $STASH ); |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# the following is set at installation time by the Makefile.PL |
|
46
|
|
|
|
|
|
|
$INSTDIR = ''; |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
#======================================================================== |
|
50
|
|
|
|
|
|
|
# --- CLASS METHODS --- |
|
51
|
|
|
|
|
|
|
#======================================================================== |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
#------------------------------------------------------------------------ |
|
54
|
|
|
|
|
|
|
# preload($module, $module, ...) |
|
55
|
|
|
|
|
|
|
# |
|
56
|
|
|
|
|
|
|
# Preloads all the standard TT modules that are likely to be used, along |
|
57
|
|
|
|
|
|
|
# with any other passed as arguments. |
|
58
|
|
|
|
|
|
|
#------------------------------------------------------------------------ |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub preload { |
|
61
|
0
|
|
|
0
|
1
|
0
|
my $class = shift; |
|
62
|
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
0
|
foreach my $module (@PRELOAD, @_) { |
|
64
|
0
|
0
|
|
|
|
0
|
$class->load($module) || return; |
|
65
|
|
|
|
|
|
|
}; |
|
66
|
0
|
|
|
|
|
0
|
return 1; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
#------------------------------------------------------------------------ |
|
71
|
|
|
|
|
|
|
# load($module) |
|
72
|
|
|
|
|
|
|
# |
|
73
|
|
|
|
|
|
|
# Load a module via require(). Any occurrences of '::' in the module name |
|
74
|
|
|
|
|
|
|
# are be converted to '/' and '.pm' is appended. Returns 1 on success |
|
75
|
|
|
|
|
|
|
# or undef on error. Use $class->error() to examine the error string. |
|
76
|
|
|
|
|
|
|
#------------------------------------------------------------------------ |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub load { |
|
79
|
1272
|
|
|
1272
|
1
|
1630
|
my ($class, $module) = @_; |
|
80
|
1272
|
|
|
|
|
3874
|
$module =~ s[::][/]g; |
|
81
|
1272
|
|
|
|
|
1369
|
$module .= '.pm'; |
|
82
|
1272
|
|
|
|
|
1099
|
eval { require $module; }; |
|
|
1272
|
|
|
|
|
161011
|
|
|
83
|
1272
|
50
|
|
|
|
4596
|
return $@ ? $class->error("failed to load $module: $@") : 1; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
#------------------------------------------------------------------------ |
|
88
|
|
|
|
|
|
|
# parser(\%params) |
|
89
|
|
|
|
|
|
|
# |
|
90
|
|
|
|
|
|
|
# Instantiate a new parser object of the class whose name is denoted by |
|
91
|
|
|
|
|
|
|
# the package variable $PARSER (default: Template::Parser). Returns |
|
92
|
|
|
|
|
|
|
# a reference to a newly instantiated parser object or undef on error. |
|
93
|
|
|
|
|
|
|
# The class error() method can be called without arguments to examine |
|
94
|
|
|
|
|
|
|
# the error message generated by this failure. |
|
95
|
|
|
|
|
|
|
#------------------------------------------------------------------------ |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub parser { |
|
98
|
139
|
|
|
139
|
1
|
2000875
|
my $class = shift; |
|
99
|
139
|
100
|
66
|
|
|
840
|
my $params = defined($_[0]) && ref($_[0]) eq 'HASH' |
|
100
|
|
|
|
|
|
|
? shift : { @_ }; |
|
101
|
|
|
|
|
|
|
|
|
102
|
139
|
50
|
|
|
|
337
|
return undef unless $class->load($PARSER); |
|
103
|
139
|
|
33
|
|
|
641
|
return $PARSER->new($params) |
|
104
|
|
|
|
|
|
|
|| $class->error("failed to create parser: ", $PARSER->error); |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
#------------------------------------------------------------------------ |
|
109
|
|
|
|
|
|
|
# provider(\%params) |
|
110
|
|
|
|
|
|
|
# |
|
111
|
|
|
|
|
|
|
# Instantiate a new template provider object (default: Template::Provider). |
|
112
|
|
|
|
|
|
|
# Returns an object reference or undef on error, as above. |
|
113
|
|
|
|
|
|
|
#------------------------------------------------------------------------ |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub provider { |
|
116
|
159
|
|
|
159
|
1
|
263
|
my $class = shift; |
|
117
|
159
|
100
|
66
|
|
|
844
|
my $params = defined($_[0]) && ref($_[0]) eq 'HASH' |
|
118
|
|
|
|
|
|
|
? shift : { @_ }; |
|
119
|
|
|
|
|
|
|
|
|
120
|
159
|
50
|
|
|
|
350
|
return undef unless $class->load($PROVIDER); |
|
121
|
159
|
|
33
|
|
|
946
|
return $PROVIDER->new($params) |
|
122
|
|
|
|
|
|
|
|| $class->error("failed to create template provider: ", |
|
123
|
|
|
|
|
|
|
$PROVIDER->error); |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
#------------------------------------------------------------------------ |
|
128
|
|
|
|
|
|
|
# plugins(\%params) |
|
129
|
|
|
|
|
|
|
# |
|
130
|
|
|
|
|
|
|
# Instantiate a new plugins provider object (default: Template::Plugins). |
|
131
|
|
|
|
|
|
|
# Returns an object reference or undef on error, as above. |
|
132
|
|
|
|
|
|
|
#------------------------------------------------------------------------ |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub plugins { |
|
135
|
159
|
|
|
159
|
1
|
211
|
my $class = shift; |
|
136
|
159
|
100
|
66
|
|
|
785
|
my $params = defined($_[0]) && ref($_[0]) eq 'HASH' |
|
137
|
|
|
|
|
|
|
? shift : { @_ }; |
|
138
|
|
|
|
|
|
|
|
|
139
|
159
|
50
|
|
|
|
331
|
return undef unless $class->load($PLUGINS); |
|
140
|
159
|
|
33
|
|
|
712
|
return $PLUGINS->new($params) |
|
141
|
|
|
|
|
|
|
|| $class->error("failed to create plugin provider: ", |
|
142
|
|
|
|
|
|
|
$PLUGINS->error); |
|
143
|
|
|
|
|
|
|
} |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
#------------------------------------------------------------------------ |
|
147
|
|
|
|
|
|
|
# filters(\%params) |
|
148
|
|
|
|
|
|
|
# |
|
149
|
|
|
|
|
|
|
# Instantiate a new filters provider object (default: Template::Filters). |
|
150
|
|
|
|
|
|
|
# Returns an object reference or undef on error, as above. |
|
151
|
|
|
|
|
|
|
#------------------------------------------------------------------------ |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub filters { |
|
154
|
159
|
|
|
159
|
1
|
314
|
my $class = shift; |
|
155
|
159
|
100
|
66
|
|
|
769
|
my $params = defined($_[0]) && ref($_[0]) eq 'HASH' |
|
156
|
|
|
|
|
|
|
? shift : { @_ }; |
|
157
|
|
|
|
|
|
|
|
|
158
|
159
|
50
|
|
|
|
373
|
return undef unless $class->load($FILTERS); |
|
159
|
159
|
|
33
|
|
|
770
|
return $FILTERS->new($params) |
|
160
|
|
|
|
|
|
|
|| $class->error("failed to create filter provider: ", |
|
161
|
|
|
|
|
|
|
$FILTERS->error); |
|
162
|
|
|
|
|
|
|
} |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
#------------------------------------------------------------------------ |
|
166
|
|
|
|
|
|
|
# iterator(\@list) |
|
167
|
|
|
|
|
|
|
# |
|
168
|
|
|
|
|
|
|
# Instantiate a new Template::Iterator object (default: Template::Iterator). |
|
169
|
|
|
|
|
|
|
# Returns an object reference or undef on error, as above. |
|
170
|
|
|
|
|
|
|
#------------------------------------------------------------------------ |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
sub iterator { |
|
173
|
174
|
|
|
174
|
1
|
2483
|
my $class = shift; |
|
174
|
174
|
|
|
|
|
153
|
my $list = shift; |
|
175
|
|
|
|
|
|
|
|
|
176
|
174
|
50
|
|
|
|
337
|
return undef unless $class->load($ITERATOR); |
|
177
|
174
|
|
33
|
|
|
533
|
return $ITERATOR->new($list, @_) |
|
178
|
|
|
|
|
|
|
|| $class->error("failed to create iterator: ", $ITERATOR->error); |
|
179
|
|
|
|
|
|
|
} |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
#------------------------------------------------------------------------ |
|
183
|
|
|
|
|
|
|
# stash(\%vars) |
|
184
|
|
|
|
|
|
|
# |
|
185
|
|
|
|
|
|
|
# Instantiate a new template variable stash object (default: |
|
186
|
|
|
|
|
|
|
# Template::Stash). Returns object or undef, as above. |
|
187
|
|
|
|
|
|
|
#------------------------------------------------------------------------ |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
sub stash { |
|
190
|
162
|
|
|
162
|
1
|
310
|
my $class = shift; |
|
191
|
162
|
100
|
66
|
|
|
751
|
my $params = defined($_[0]) && ref($_[0]) eq 'HASH' |
|
192
|
|
|
|
|
|
|
? shift : { @_ }; |
|
193
|
|
|
|
|
|
|
|
|
194
|
162
|
50
|
|
|
|
326
|
return undef unless $class->load($STASH); |
|
195
|
162
|
|
33
|
|
|
807
|
return $STASH->new($params) |
|
196
|
|
|
|
|
|
|
|| $class->error("failed to create stash: ", $STASH->error); |
|
197
|
|
|
|
|
|
|
} |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
#------------------------------------------------------------------------ |
|
201
|
|
|
|
|
|
|
# context(\%params) |
|
202
|
|
|
|
|
|
|
# |
|
203
|
|
|
|
|
|
|
# Instantiate a new template context object (default: Template::Context). |
|
204
|
|
|
|
|
|
|
# Returns object or undef, as above. |
|
205
|
|
|
|
|
|
|
#------------------------------------------------------------------------ |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
sub context { |
|
208
|
158
|
|
|
158
|
1
|
247
|
my $class = shift; |
|
209
|
158
|
100
|
100
|
|
|
813
|
my $params = defined($_[0]) && ref($_[0]) eq 'HASH' |
|
210
|
|
|
|
|
|
|
? shift : { @_ }; |
|
211
|
|
|
|
|
|
|
|
|
212
|
158
|
50
|
|
|
|
316
|
return undef unless $class->load($CONTEXT); |
|
213
|
158
|
|
33
|
|
|
950
|
return $CONTEXT->new($params) |
|
214
|
|
|
|
|
|
|
|| $class->error("failed to create context: ", $CONTEXT->error); |
|
215
|
|
|
|
|
|
|
} |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
#------------------------------------------------------------------------ |
|
219
|
|
|
|
|
|
|
# service(\%params) |
|
220
|
|
|
|
|
|
|
# |
|
221
|
|
|
|
|
|
|
# Instantiate a new template context object (default: Template::Service). |
|
222
|
|
|
|
|
|
|
# Returns object or undef, as above. |
|
223
|
|
|
|
|
|
|
#------------------------------------------------------------------------ |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
sub service { |
|
226
|
155
|
|
|
155
|
1
|
221
|
my $class = shift; |
|
227
|
155
|
100
|
66
|
|
|
893
|
my $params = defined($_[0]) && ref($_[0]) eq 'HASH' |
|
228
|
|
|
|
|
|
|
? shift : { @_ }; |
|
229
|
|
|
|
|
|
|
|
|
230
|
155
|
50
|
|
|
|
447
|
return undef unless $class->load($SERVICE); |
|
231
|
155
|
|
33
|
|
|
1139
|
return $SERVICE->new($params) |
|
232
|
|
|
|
|
|
|
|| $class->error("failed to create context: ", $SERVICE->error); |
|
233
|
|
|
|
|
|
|
} |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
#------------------------------------------------------------------------ |
|
237
|
|
|
|
|
|
|
# constants(\%params) |
|
238
|
|
|
|
|
|
|
# |
|
239
|
|
|
|
|
|
|
# Instantiate a new namespace handler for compile time constant folding |
|
240
|
|
|
|
|
|
|
# (default: Template::Namespace::Constants). |
|
241
|
|
|
|
|
|
|
# Returns object or undef, as above. |
|
242
|
|
|
|
|
|
|
#------------------------------------------------------------------------ |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
sub constants { |
|
245
|
7
|
|
|
7
|
1
|
9
|
my $class = shift; |
|
246
|
7
|
50
|
33
|
|
|
36
|
my $params = defined($_[0]) && ref($_[0]) eq 'HASH' |
|
247
|
|
|
|
|
|
|
? shift : { @_ }; |
|
248
|
|
|
|
|
|
|
|
|
249
|
7
|
50
|
|
|
|
15
|
return undef unless $class->load($CONSTANTS); |
|
250
|
7
|
|
33
|
|
|
58
|
return $CONSTANTS->new($params) |
|
251
|
|
|
|
|
|
|
|| $class->error("failed to create constants namespace: ", |
|
252
|
|
|
|
|
|
|
$CONSTANTS->error); |
|
253
|
|
|
|
|
|
|
} |
|
254
|
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
#------------------------------------------------------------------------ |
|
257
|
|
|
|
|
|
|
# instdir($dir) |
|
258
|
|
|
|
|
|
|
# |
|
259
|
|
|
|
|
|
|
# Returns the root installation directory appended with any local |
|
260
|
|
|
|
|
|
|
# component directory passed as an argument. |
|
261
|
|
|
|
|
|
|
#------------------------------------------------------------------------ |
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
sub instdir { |
|
264
|
2
|
|
|
2
|
1
|
7
|
my ($class, $dir) = @_; |
|
265
|
2
|
|
50
|
|
|
10
|
my $inst = $INSTDIR |
|
266
|
|
|
|
|
|
|
|| return $class->error("no installation directory"); |
|
267
|
0
|
|
|
|
|
0
|
$inst =~ s[/$][]g; |
|
268
|
0
|
0
|
|
|
|
0
|
$inst .= "/$dir" if $dir; |
|
269
|
0
|
|
|
|
|
0
|
return $inst; |
|
270
|
|
|
|
|
|
|
} |
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
#======================================================================== |
|
274
|
|
|
|
|
|
|
# This should probably be moved somewhere else in the long term, but for |
|
275
|
|
|
|
|
|
|
# now it ensures that Template::TieString is available even if the |
|
276
|
|
|
|
|
|
|
# Template::Directive module hasn't been loaded, as is the case when |
|
277
|
|
|
|
|
|
|
# using compiled templates and Template::Parser hasn't yet been loaded |
|
278
|
|
|
|
|
|
|
# on demand. |
|
279
|
|
|
|
|
|
|
#======================================================================== |
|
280
|
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
#------------------------------------------------------------------------ |
|
282
|
|
|
|
|
|
|
# simple package for tying $output variable to STDOUT, used by perl() |
|
283
|
|
|
|
|
|
|
#------------------------------------------------------------------------ |
|
284
|
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
package Template::TieString; |
|
286
|
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
sub TIEHANDLE { |
|
288
|
13
|
|
|
13
|
|
146
|
my ($class, $textref) = @_; |
|
289
|
13
|
|
|
|
|
49
|
bless $textref, $class; |
|
290
|
|
|
|
|
|
|
} |
|
291
|
|
|
|
|
|
|
sub PRINT { |
|
292
|
7
|
|
|
7
|
|
366
|
my $self = shift; |
|
293
|
7
|
|
|
|
|
82
|
$$self .= join('', @_); |
|
294
|
|
|
|
|
|
|
} |
|
295
|
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
1; |
|
299
|
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
__END__ |