line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Template::Like; |
2
|
|
|
|
|
|
|
|
3
|
13
|
|
|
13
|
|
491891
|
use strict; |
|
13
|
|
|
|
|
34
|
|
|
13
|
|
|
|
|
551
|
|
4
|
13
|
|
|
13
|
|
76
|
use File::Spec; |
|
13
|
|
|
|
|
32
|
|
|
13
|
|
|
|
|
273
|
|
5
|
13
|
|
|
13
|
|
15396
|
use IO::File; |
|
13
|
|
|
|
|
224925
|
|
|
13
|
|
|
|
|
1970
|
|
6
|
|
|
|
|
|
|
|
7
|
13
|
|
|
13
|
|
10419
|
use Template::Like::Processor; |
|
13
|
|
|
|
|
51
|
|
|
13
|
|
|
|
|
5039
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
$Template::Like::VERSION = '0.12'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
#===================================================================== |
12
|
|
|
|
|
|
|
# new |
13
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
14
|
|
|
|
|
|
|
# - API |
15
|
|
|
|
|
|
|
# $instance = Template::Like->new( %option ) |
16
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
17
|
|
|
|
|
|
|
# - args |
18
|
|
|
|
|
|
|
# %option ... see also pod. ( HASHREF ) |
19
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
20
|
|
|
|
|
|
|
# - Example |
21
|
|
|
|
|
|
|
# my $t = Template::Like->new( TAG_STYLE => 'asp' ); |
22
|
|
|
|
|
|
|
#===================================================================== |
23
|
|
|
|
|
|
|
sub new { |
24
|
31
|
|
|
31
|
0
|
7562
|
my $class = shift; |
25
|
|
|
|
|
|
|
|
26
|
31
|
100
|
|
|
|
191
|
my $self = bless { |
27
|
|
|
|
|
|
|
OPTION => ref $_[0] ? $_[0] : { @_ }, |
28
|
|
|
|
|
|
|
}, $class; |
29
|
|
|
|
|
|
|
|
30
|
31
|
|
|
|
|
86
|
return $self; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
#===================================================================== |
36
|
|
|
|
|
|
|
# process |
37
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
38
|
|
|
|
|
|
|
# - API |
39
|
|
|
|
|
|
|
# $rc = $t->process( $input, $params, $output, $option ); |
40
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
41
|
|
|
|
|
|
|
# - args |
42
|
|
|
|
|
|
|
# $input ... INPUT ( SCALAR, SCALARREF, ARRAYREF, HASHREF, GLOB ) |
43
|
|
|
|
|
|
|
# $params ... PARAMS ( HASHREF ) |
44
|
|
|
|
|
|
|
# $output ... OUTPUT ( SCALAR, SCALARREF, ARRAYREF, HASHREF, GLOB, Apache::Request ) |
45
|
|
|
|
|
|
|
# $option ... see also pod. ( HASHREF ) |
46
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
47
|
|
|
|
|
|
|
# - Example |
48
|
|
|
|
|
|
|
# $t->process( $input, $params, $output, $option ) || die $t->error(); |
49
|
|
|
|
|
|
|
#===================================================================== |
50
|
|
|
|
|
|
|
sub process { |
51
|
103
|
|
|
103
|
0
|
114971
|
my $self = shift; |
52
|
103
|
|
50
|
|
|
443
|
my $input = shift || undef; |
53
|
103
|
|
50
|
|
|
921
|
my $params = shift || {}; |
54
|
103
|
|
50
|
|
|
568
|
my $output = shift || undef; |
55
|
103
|
|
100
|
|
|
773
|
my $option = shift || {}; |
56
|
|
|
|
|
|
|
|
57
|
103
|
|
|
|
|
182
|
eval { |
58
|
103
|
|
|
|
|
671
|
my $processor = Template::Like::Processor->new( $self->_option, $params, $option ); |
59
|
|
|
|
|
|
|
|
60
|
103
|
|
|
|
|
313
|
$processor->finalize( $processor->process( $input ), $output ); |
61
|
|
|
|
|
|
|
}; |
62
|
|
|
|
|
|
|
|
63
|
103
|
|
|
|
|
395
|
$self->error($@); |
64
|
|
|
|
|
|
|
|
65
|
103
|
100
|
|
|
|
2821
|
die $@ if $@; |
66
|
101
|
50
|
|
|
|
195
|
return if $@; |
67
|
101
|
|
|
|
|
288
|
return 1; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
#===================================================================== |
74
|
|
|
|
|
|
|
# error |
75
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
76
|
|
|
|
|
|
|
# - API |
77
|
|
|
|
|
|
|
# $error = $t->error(); |
78
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
79
|
|
|
|
|
|
|
# - returns |
80
|
|
|
|
|
|
|
# $error ... Error Message. |
81
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
82
|
|
|
|
|
|
|
# - Example |
83
|
|
|
|
|
|
|
# $t->process( $input, $params, $output, $option ) || die $t->error(); |
84
|
|
|
|
|
|
|
#===================================================================== |
85
|
|
|
|
|
|
|
sub error { |
86
|
103
|
50
|
|
103
|
0
|
440
|
$_[0]->{'ERROR'} = $_[1] if @_ > 1; |
87
|
103
|
|
|
|
|
188
|
$_[0]->{'ERROR'}; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
103
|
|
|
103
|
|
811
|
sub _option { $_[0]->{'OPTION'}; } |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=pod |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 NAME |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Template::Like - Lightweight Template Engine. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 SYNOPSIS |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
#!/usr/bin/perl |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
use lib 'lib'; |
103
|
|
|
|
|
|
|
use strict; |
104
|
|
|
|
|
|
|
use Template::Like; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
my $input = q{ |
107
|
|
|
|
|
|
|
[% var %] |
108
|
|
|
|
|
|
|
[% FOREACH var = vars %] |
109
|
|
|
|
|
|
|
- [% var.name %] |
110
|
|
|
|
|
|
|
[% END %] |
111
|
|
|
|
|
|
|
[% var %] |
112
|
|
|
|
|
|
|
[% IF bool %]TURE!![% ELSE %]FALSE!![% END %] |
113
|
|
|
|
|
|
|
[% UNLESS bool %]TURE!![% ELSE %]FALSE!![% END %] |
114
|
|
|
|
|
|
|
}; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
my $param = { |
117
|
|
|
|
|
|
|
var => "HOGE", |
118
|
|
|
|
|
|
|
vars => [ { name => "FOO" }, { name => "BAR" } ], |
119
|
|
|
|
|
|
|
bool => 1 |
120
|
|
|
|
|
|
|
}; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
my $t = Template::Like->new; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
my $output = ""; |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
$t->process(\$input, $param, \$output); |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
print $output; |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
exit; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
result |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
HOGE |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
- FOO |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
- BAR |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
HOGE |
143
|
|
|
|
|
|
|
TURE!! |
144
|
|
|
|
|
|
|
FALSE!! |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 DESCRIPTION |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head2 Directive |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=over 4 |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=item GET |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=item SET |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=item USE |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=item CALL |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=item FOREACH |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=item WHILE |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=item IF |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=item UNLESS |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=item ELSIF |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=item ELSE |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=item END |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=item FILTER |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=item DUMMY |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=item INSERT |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=item INCLUDE |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=item PROCESS |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=back |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head2 VMethods |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head3 scalar |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=over 4 |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=item defined |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=item length |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=item repeat |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=item replace |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=item match |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=item search |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=item split |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=item list |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=item hash |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=item size |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=item substr |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=item html |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=item uri |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=back |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=head3 array |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=over 4 |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=item first |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=item last |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=item size |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=item max |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=item reverse |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=item join |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=item grep |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=item sort |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=item nsort |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=item unshift |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=item push |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=item shift |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=item pop |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=item unique |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=item merge |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=item slice |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
=item splice |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=item list |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=back |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
=head3 hash |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
=over 4 |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=item keys |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=item values |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
=item each |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
=item defined |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
=item exists |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
=item size |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
=item item |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
=item list |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
=back |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
official L |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
=head1 SEE ALSO |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
L |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
=head1 AUTHOR |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
Shinichiro Aska, Easkadna@cpan.orgE |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
Copyright (C) 2007 by Shinichiro Aska |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
300
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.5 or, |
301
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
=cut |