| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package CGI::Application::Plugin::AnyTemplate::Driver::TemplateToolkit; |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
CGI::Application::Plugin::AnyTemplate::Driver::TemplateToolkit - Template::Toolkit plugin to AnyTemplate |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
This is a driver for L, which |
|
11
|
|
|
|
|
|
|
provides the implementation details specific to rendering templates via |
|
12
|
|
|
|
|
|
|
the L templating system. |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
All C drivers are designed to be used the same way. For |
|
15
|
|
|
|
|
|
|
general usage instructions, see the documentation of |
|
16
|
|
|
|
|
|
|
L. |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 EMBEDDED COMPONENT SYNTAX (Template::Toolkit) |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
The L syntax for embedding components is: |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
[% CGIAPP.embed("some_run_mode", param1, param2, 'literal string3') %] |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
This can be overridden by the following configuration variables: |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
embed_tag_name # default 'CGIAPP' |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
For instance by setting the following values in your configuration file: |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
embed_tag_name 'MYAPP' |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Then the embedded component tag will look like: |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
[% MYAPP.embed("some_run_mode") %] |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 TT OBJECT CACHING (singleton support) |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head2 Introduction |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
In a persistent environment, rather than creating a L |
|
42
|
|
|
|
|
|
|
object each time you fill a template, it is much more efficient to load |
|
43
|
|
|
|
|
|
|
a single L object and use this object to render all |
|
44
|
|
|
|
|
|
|
of your templates. |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
However, in a persistent environment, you may have several different |
|
47
|
|
|
|
|
|
|
applications running, and they all might need to set different |
|
48
|
|
|
|
|
|
|
L options (such as C, etc.). |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
By default, when the C driver creates a |
|
51
|
|
|
|
|
|
|
L object, it caches it. From that point on, whenever |
|
52
|
|
|
|
|
|
|
the same application needs a L object, the driver |
|
53
|
|
|
|
|
|
|
uses the cached object rather than creating a new one. |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 Multiple Applications in a Shared Persistent Environment |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
An attempt is made to prevent different applications from |
|
58
|
|
|
|
|
|
|
sharing the same TT object. |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Internally, the TT objects are stored in a private hash keyed by the web |
|
61
|
|
|
|
|
|
|
application's class name. |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
You can explicitly specify the class name when you call C: |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
$self->template->config( |
|
66
|
|
|
|
|
|
|
type => 'TemplateToolkit', |
|
67
|
|
|
|
|
|
|
TemplateToolkit => { |
|
68
|
|
|
|
|
|
|
storage_class => 'My::Project', |
|
69
|
|
|
|
|
|
|
}, |
|
70
|
|
|
|
|
|
|
); |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
If you don't specify the class name, then the package containing the subroutine |
|
73
|
|
|
|
|
|
|
that called C is used. For instance: |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
package My::Project; |
|
76
|
|
|
|
|
|
|
sub setup { |
|
77
|
|
|
|
|
|
|
my $self = shift; |
|
78
|
|
|
|
|
|
|
$self->template->config( # My::Project is used to store |
|
79
|
|
|
|
|
|
|
type => 'TemplateToolkit', # cached TT object |
|
80
|
|
|
|
|
|
|
); |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
A typical C module hierarchy looks like this: |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
CGI::Application |
|
86
|
|
|
|
|
|
|
My::Project |
|
87
|
|
|
|
|
|
|
My::Webapp |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
In this hierarchy, it makes sense to store the cached TT object in |
|
90
|
|
|
|
|
|
|
C. To make this happen, either call C<< $self->template->config >> |
|
91
|
|
|
|
|
|
|
from within C, or explicitly name the C when you call |
|
92
|
|
|
|
|
|
|
C<< $self->template->config >>. |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 Disabling TT Object Caching |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
You can disable L object caching entirely by |
|
97
|
|
|
|
|
|
|
providing a false value to the C driver config |
|
98
|
|
|
|
|
|
|
parameter: |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
$self->template->config( |
|
101
|
|
|
|
|
|
|
type => 'TemplateToolkit', |
|
102
|
|
|
|
|
|
|
TemplateToolkit => { |
|
103
|
|
|
|
|
|
|
object_caching => 0, |
|
104
|
|
|
|
|
|
|
}, |
|
105
|
|
|
|
|
|
|
); |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 TT Object Caching and Include Paths |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
The C driver config parameter is not cached; it is set |
|
110
|
|
|
|
|
|
|
every time you call C<< $self->template->load >>. So you can safely used |
|
111
|
|
|
|
|
|
|
cached TT objects even if the applications sharing the TT object need |
|
112
|
|
|
|
|
|
|
different C. |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=cut |
|
115
|
|
|
|
|
|
|
|
|
116
|
22
|
|
|
22
|
|
71307
|
use strict; |
|
|
22
|
|
|
|
|
133
|
|
|
|
22
|
|
|
|
|
827
|
|
|
117
|
22
|
|
|
22
|
|
119
|
use Carp; |
|
|
22
|
|
|
|
|
46
|
|
|
|
22
|
|
|
|
|
1580
|
|
|
118
|
|
|
|
|
|
|
|
|
119
|
22
|
|
|
22
|
|
1950
|
use CGI::Application::Plugin::AnyTemplate::ComponentHandler; |
|
|
22
|
|
|
|
|
44
|
|
|
|
22
|
|
|
|
|
497
|
|
|
120
|
|
|
|
|
|
|
|
|
121
|
22
|
|
|
22
|
|
2091
|
use CGI::Application::Plugin::AnyTemplate::Base; |
|
|
22
|
|
|
|
|
42
|
|
|
|
22
|
|
|
|
|
578
|
|
|
122
|
22
|
|
|
22
|
|
111
|
use vars qw(@ISA); |
|
|
22
|
|
|
|
|
42
|
|
|
|
22
|
|
|
|
|
14052
|
|
|
123
|
|
|
|
|
|
|
@ISA = ('CGI::Application::Plugin::AnyTemplate::Base'); |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 CONFIGURATION |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
The L driver |
|
128
|
|
|
|
|
|
|
accepts the following config parameters: |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=over 4 |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item embed_tag_name |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
The name of the tag used for embedding components. Defaults to |
|
135
|
|
|
|
|
|
|
C. |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=item template_extension |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
If C is true, then |
|
140
|
|
|
|
|
|
|
L will append the value of |
|
141
|
|
|
|
|
|
|
C to C. By default |
|
142
|
|
|
|
|
|
|
the C is C<.xhtml>. |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=item emulate_associate_query |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
B |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
If this config parameter is true, then L |
|
149
|
|
|
|
|
|
|
will copy all of the webapp's query params into the template. |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
This is similar to what would happen if you used L's |
|
152
|
|
|
|
|
|
|
C feature with the webapp's query object: |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
my $driver = HTML::Template->new( |
|
155
|
|
|
|
|
|
|
associate => $self->query, |
|
156
|
|
|
|
|
|
|
); |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
By default C is false. |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=item object_caching |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Whether or not to cache the L object in a persistent environment |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
By default, C is enabled. |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
See L<"TT OBJECT CACHING (singleton support)">, above. |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=item storage_class |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
What class to use as the storage key when object caching is enabled. |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
By default, C defaults to the package containing the |
|
173
|
|
|
|
|
|
|
subroutine that called C<< $self->template->config >>. |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
See L<"TT OBJECT CACHING (singleton support)">, above. |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=back |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
All other configuration parameters are passed on unchanged to L. |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=head1 CONFIGURING UTF-8 TEMPLATES |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
C does NOT support L's C option at runtime: |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
# not possible with AnyTemplate |
|
187
|
|
|
|
|
|
|
$tt->process($infile, $vars, $outfile, { binmode => 1 }) |
|
188
|
|
|
|
|
|
|
|| die $tt->error(), "\n"; |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
# not possible with AnyTemplate |
|
191
|
|
|
|
|
|
|
$tt->process($infile, $vars, $outfile, binmode => 1) |
|
192
|
|
|
|
|
|
|
|| die $tt->error(), "\n"; |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
# not possible with AnyTemplate |
|
195
|
|
|
|
|
|
|
$tt->process($infile, $vars, $outfile, binmode => ':utf8') |
|
196
|
|
|
|
|
|
|
|| die $tt->error(), "\n"; |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
Instead, use the C option in the initial config: |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
$self->template->config( |
|
201
|
|
|
|
|
|
|
default_type => 'TemplateToolkit', |
|
202
|
|
|
|
|
|
|
TemplateToolkit => { |
|
203
|
|
|
|
|
|
|
ENCODING => 'UTF-8' |
|
204
|
|
|
|
|
|
|
} |
|
205
|
|
|
|
|
|
|
); |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
If you have a mix of encodings in your templates, use a separate |
|
208
|
|
|
|
|
|
|
C configuration for each encoding: |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
$self->template('ascii')->config( |
|
211
|
|
|
|
|
|
|
default_type => 'TemplateToolkit', |
|
212
|
|
|
|
|
|
|
); |
|
213
|
|
|
|
|
|
|
$self->template('utf-8')->config( |
|
214
|
|
|
|
|
|
|
default_type => 'TemplateToolkit', |
|
215
|
|
|
|
|
|
|
TemplateToolkit => { |
|
216
|
|
|
|
|
|
|
ENCODING => 'UTF-8' |
|
217
|
|
|
|
|
|
|
} |
|
218
|
|
|
|
|
|
|
); |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=cut |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
sub driver_config_keys { |
|
223
|
81
|
|
|
81
|
1
|
396
|
qw/ |
|
224
|
|
|
|
|
|
|
storage_class |
|
225
|
|
|
|
|
|
|
object_caching |
|
226
|
|
|
|
|
|
|
cache_storage_keys |
|
227
|
|
|
|
|
|
|
embed_tag_name |
|
228
|
|
|
|
|
|
|
template_extension |
|
229
|
|
|
|
|
|
|
emulate_associate_query |
|
230
|
|
|
|
|
|
|
/; |
|
231
|
|
|
|
|
|
|
} |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
sub default_driver_config { |
|
234
|
|
|
|
|
|
|
( |
|
235
|
81
|
|
|
81
|
1
|
616
|
object_caching => 1, |
|
236
|
|
|
|
|
|
|
template_extension => '.tmpl', |
|
237
|
|
|
|
|
|
|
embed_tag_name => 'CGIAPP', |
|
238
|
|
|
|
|
|
|
emulate_associate_query => 0, |
|
239
|
|
|
|
|
|
|
); |
|
240
|
|
|
|
|
|
|
} |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=head2 required_modules |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
The C function returns the modules required for this driver |
|
245
|
|
|
|
|
|
|
to operate. In this case: C. |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=cut |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
sub required_modules { |
|
250
|
88
|
|
|
88
|
1
|
2433
|
return qw( |
|
251
|
|
|
|
|
|
|
Template |
|
252
|
|
|
|
|
|
|
); |
|
253
|
|
|
|
|
|
|
} |
|
254
|
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=head1 DRIVER METHODS |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
=over 4 |
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=item initialize |
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
Initializes the C driver. See the docs for |
|
262
|
|
|
|
|
|
|
L for details. |
|
263
|
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
=cut |
|
265
|
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
# create the Template::Toolkit object, |
|
267
|
|
|
|
|
|
|
# using: |
|
268
|
|
|
|
|
|
|
# $self->{'driver_config'} # config info |
|
269
|
|
|
|
|
|
|
# $self->{'include_paths'} # the paths to search for the template file |
|
270
|
|
|
|
|
|
|
# $self->filename # the template file |
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
my %TT_Object_Store; |
|
273
|
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
sub initialize { |
|
275
|
66
|
|
|
66
|
1
|
124
|
my $self = shift; |
|
276
|
|
|
|
|
|
|
|
|
277
|
66
|
|
|
|
|
411
|
$self->_require_prerequisite_modules; |
|
278
|
|
|
|
|
|
|
|
|
279
|
66
|
|
|
|
|
111
|
my %config = %{ $self->{'native_config'} }; |
|
|
66
|
|
|
|
|
421
|
|
|
280
|
66
|
|
|
|
|
361
|
$config{'INCLUDE_PATH'} = $self->{'include_paths'}; |
|
281
|
|
|
|
|
|
|
|
|
282
|
66
|
|
|
|
|
122
|
my $driver; |
|
283
|
66
|
|
|
|
|
154
|
my $storage_class = $self->{'driver_config'}{'storage_class'}; |
|
284
|
66
|
|
66
|
|
|
530
|
$storage_class ||= $self->{'callers_package'}; |
|
285
|
|
|
|
|
|
|
|
|
286
|
66
|
|
|
|
|
122
|
my $config_name = $self->{'conf_name'}; |
|
287
|
|
|
|
|
|
|
|
|
288
|
66
|
100
|
100
|
|
|
512
|
if ($self->{'driver_config'}{'object_caching'} and exists $TT_Object_Store{$storage_class}) { |
|
289
|
31
|
100
|
|
|
|
103
|
if (defined $config_name) { |
|
290
|
13
|
|
|
|
|
43
|
$driver = $TT_Object_Store{$storage_class}{'named'}{$config_name}; |
|
291
|
|
|
|
|
|
|
} |
|
292
|
|
|
|
|
|
|
else { |
|
293
|
18
|
|
|
|
|
62
|
$driver = $TT_Object_Store{$storage_class}{'default'}; |
|
294
|
|
|
|
|
|
|
} |
|
295
|
|
|
|
|
|
|
} |
|
296
|
66
|
100
|
|
|
|
223
|
if (!$driver) { |
|
297
|
43
|
|
|
|
|
376
|
$driver = Template->new(\%config); |
|
298
|
|
|
|
|
|
|
} |
|
299
|
66
|
100
|
|
|
|
644334
|
if ($self->{'driver_config'}{'object_caching'}) { |
|
300
|
58
|
100
|
|
|
|
214
|
if (defined $config_name) { |
|
301
|
25
|
|
|
|
|
94
|
$TT_Object_Store{$storage_class}{'named'}{$config_name} = $driver; |
|
302
|
|
|
|
|
|
|
} |
|
303
|
|
|
|
|
|
|
else { |
|
304
|
33
|
|
|
|
|
122
|
$TT_Object_Store{$storage_class}{'default'} = $driver; |
|
305
|
|
|
|
|
|
|
} |
|
306
|
|
|
|
|
|
|
} |
|
307
|
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
# Stolen from Cees's CAP::TT |
|
309
|
66
|
|
|
|
|
313
|
$driver->context->load_templates->[0]->include_path($self->{'include_paths'}); |
|
310
|
|
|
|
|
|
|
|
|
311
|
66
|
|
|
|
|
2429
|
$self->{'driver'} = $driver; |
|
312
|
|
|
|
|
|
|
} |
|
313
|
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
=item render_template |
|
315
|
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
Fills the L object with C<< $self->param >> |
|
317
|
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
If the param C is true, then set params for |
|
319
|
|
|
|
|
|
|
each of $self->{'webapp'}->query, mimicking L's |
|
320
|
|
|
|
|
|
|
associate mechanism. |
|
321
|
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
Also set up a L |
|
323
|
|
|
|
|
|
|
object so that the C callback will work. |
|
324
|
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
Returns the output of the filled template as a string reference. |
|
326
|
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
See the docs for L for details. |
|
328
|
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
=back |
|
330
|
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
=cut |
|
332
|
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
sub render_template { |
|
334
|
50
|
|
|
50
|
1
|
107
|
my $self = shift; |
|
335
|
|
|
|
|
|
|
|
|
336
|
50
|
|
|
|
|
106
|
my $driver_config = $self->{'driver_config'}; |
|
337
|
|
|
|
|
|
|
|
|
338
|
50
|
|
|
|
|
101
|
my $template = $self->{'driver'}; |
|
339
|
|
|
|
|
|
|
|
|
340
|
50
|
|
|
|
|
95
|
my $output = ''; |
|
341
|
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
# emulate HTML::Template's 'associate' behaviour |
|
343
|
|
|
|
|
|
|
|
|
344
|
50
|
100
|
|
|
|
196
|
if ($driver_config->{'emulate_associate_query'}) { |
|
345
|
1
|
|
|
|
|
9
|
my $params = $self->get_param_hash; |
|
346
|
1
|
50
|
|
|
|
9
|
if ($self->{'webapp'}) { |
|
347
|
1
|
|
|
|
|
7
|
foreach ($self->{'webapp'}->query->param) { |
|
348
|
3
|
|
66
|
|
|
87
|
$params->{$_} ||= $self->{'webapp'}->query->param($_); |
|
349
|
|
|
|
|
|
|
} |
|
350
|
|
|
|
|
|
|
} |
|
351
|
|
|
|
|
|
|
} |
|
352
|
|
|
|
|
|
|
|
|
353
|
50
|
|
|
|
|
637
|
my $component_handler = $self->{'component_handler_class'}->new( |
|
354
|
|
|
|
|
|
|
'webapp' => $self->{'webapp'}, |
|
355
|
|
|
|
|
|
|
'containing_template' => $self, |
|
356
|
|
|
|
|
|
|
); |
|
357
|
|
|
|
|
|
|
|
|
358
|
50
|
|
|
|
|
286
|
my $params = $self->get_param_hash; |
|
359
|
50
|
|
|
|
|
167
|
$params->{$driver_config->{'embed_tag_name'}} = $component_handler; |
|
360
|
|
|
|
|
|
|
|
|
361
|
50
|
|
|
|
|
325
|
my $filename = $self->filename; |
|
362
|
50
|
|
|
|
|
283
|
my $string_ref = $self->string_ref; |
|
363
|
|
|
|
|
|
|
|
|
364
|
50
|
50
|
66
|
|
|
320
|
$string_ref or $filename or croak "TemplateToolkit: file or string must be specified"; |
|
365
|
|
|
|
|
|
|
|
|
366
|
50
|
100
|
66
|
|
|
433
|
$template->process(($string_ref || $filename), $params, \$output) || croak $template->error; |
|
367
|
49
|
|
|
|
|
884895
|
return \$output; |
|
368
|
|
|
|
|
|
|
|
|
369
|
|
|
|
|
|
|
} |
|
370
|
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
372
|
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
CGI::Application::Plugin::AnyTemplate |
|
374
|
|
|
|
|
|
|
CGI::Application::Plugin::AnyTemplate::Base |
|
375
|
|
|
|
|
|
|
CGI::Application::Plugin::AnyTemplate::ComponentHandler |
|
376
|
|
|
|
|
|
|
CGI::Application::Plugin::AnyTemplate::Driver::HTMLTemplate |
|
377
|
|
|
|
|
|
|
CGI::Application::Plugin::AnyTemplate::Driver::HTMLTemplateExpr |
|
378
|
|
|
|
|
|
|
CGI::Application::Plugin::AnyTemplate::Driver::HTMLTemplatePluggable |
|
379
|
|
|
|
|
|
|
CGI::Application::Plugin::AnyTemplate::Driver::Petal |
|
380
|
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
CGI::Application |
|
382
|
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
Template::Toolkit |
|
384
|
|
|
|
|
|
|
HTML::Template |
|
385
|
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
HTML::Template::Pluggable |
|
387
|
|
|
|
|
|
|
HTML::Template::Plugin::Dot |
|
388
|
|
|
|
|
|
|
|
|
389
|
|
|
|
|
|
|
Petal |
|
390
|
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
Exporter::Renaming |
|
392
|
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
CGI::Application::Plugin::TT |
|
394
|
|
|
|
|
|
|
|
|
395
|
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
397
|
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
Thanks to Cees Hek for discussing the issues of caching in a persistent |
|
399
|
|
|
|
|
|
|
environment. And also for his excellent L |
|
400
|
|
|
|
|
|
|
module, from which I stole ideas and some code: especially the bit |
|
401
|
|
|
|
|
|
|
about how to change the include path in a TT object after you've |
|
402
|
|
|
|
|
|
|
initialized it. |
|
403
|
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
=head1 AUTHOR |
|
405
|
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
Michael Graham, C<< >> |
|
407
|
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
409
|
|
|
|
|
|
|
|
|
410
|
|
|
|
|
|
|
Copyright 2005 Michael Graham, All Rights Reserved. |
|
411
|
|
|
|
|
|
|
|
|
412
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
413
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
414
|
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
=cut |
|
416
|
|
|
|
|
|
|
|
|
417
|
|
|
|
|
|
|
1; |
|
418
|
|
|
|
|
|
|
|
|
419
|
|
|
|
|
|
|
|