| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package HTML::Template::Filter::Dreamweaver; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
10886
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
37
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
38
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
require Exporter; |
|
7
|
1
|
|
|
1
|
|
7689
|
use AutoLoader qw(AUTOLOAD); |
|
|
1
|
|
|
|
|
1620
|
|
|
|
1
|
|
|
|
|
6
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export |
|
12
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead. |
|
13
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants. |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# This allows declaration use HTML::Template::Filter::Dreamweaver ':all'; |
|
16
|
|
|
|
|
|
|
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK |
|
17
|
|
|
|
|
|
|
# will save memory. |
|
18
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw( DWT2HTML DWT2HTMLExpr |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
) ] ); |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
our @EXPORT = qw( |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
); |
|
27
|
|
|
|
|
|
|
our $VERSION = '1.01'; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# Preloaded methods go here. |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Autoload methods go after =cut, and are processed by the autosplit program. |
|
33
|
|
|
|
|
|
|
sub escapeQuote { |
|
34
|
232
|
|
|
232
|
0
|
321
|
my $toencode = shift; |
|
35
|
|
|
|
|
|
|
|
|
36
|
232
|
100
|
|
|
|
609
|
if ( $toencode !~ /\'/ ) { return "'$toencode'"; } |
|
|
171
|
50
|
|
|
|
973
|
|
|
37
|
61
|
|
|
|
|
229
|
elsif ( $toencode !~ /\"/ ) { return "\"$toencode\""; } |
|
38
|
|
|
|
|
|
|
else { |
|
39
|
0
|
|
|
|
|
0
|
$toencode =~ s{\"}{\'}gso; |
|
40
|
0
|
|
|
|
|
0
|
return "\"$toencode\""; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub handleTemplateEditable { |
|
45
|
6
|
|
|
6
|
0
|
21
|
my $str = shift; |
|
46
|
6
|
|
|
|
|
12
|
my $default = shift; |
|
47
|
|
|
|
|
|
|
|
|
48
|
6
|
|
|
|
|
9
|
my $ret = ""; |
|
64
|
6
|
|
|
|
|
22
|
return $ret; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub handleTernary { |
|
68
|
3
|
|
|
3
|
0
|
5
|
my $str = shift; |
|
69
|
3
|
|
|
|
|
4
|
my $defaults = shift; |
|
70
|
3
|
|
|
|
|
3
|
my $use_expr = shift; |
|
71
|
|
|
|
|
|
|
|
|
72
|
3
|
|
|
|
|
19
|
my ( $char, $expr ) = $str =~ m{\s[Ee][Xx][Pp][Rr]\s*=\s*([\"\'])(.*?)\1}s; |
|
73
|
|
|
|
|
|
|
|
|
74
|
3
|
|
|
|
|
16
|
my ( $if, $true, $false ) = $expr =~ m{(.*)\?(.*)\:(.*)}; |
|
75
|
|
|
|
|
|
|
|
|
76
|
3
|
|
|
|
|
7
|
$if =~ s/^\s+//g; |
|
77
|
3
|
|
|
|
|
13
|
$if =~ s/\s+$//g; |
|
78
|
3
|
|
|
|
|
10
|
$true =~ s/^\s+//g; |
|
79
|
3
|
|
|
|
|
10
|
$true =~ s/\s+$//g; |
|
80
|
3
|
|
|
|
|
11
|
$false =~ s/^\s+//g; |
|
81
|
3
|
|
|
|
|
5
|
$false =~ s/\s+$//g; |
|
82
|
|
|
|
|
|
|
|
|
83
|
3
|
|
|
|
|
17
|
while ( $true =~ m{([\w\'\"]+)}sg ) { |
|
84
|
3
|
50
|
|
|
|
18
|
if ( $defaults->{ $1 } ) { |
|
85
|
0
|
|
|
|
|
0
|
$true = handleTemplateExpr( "cond=" . escapeQuote($true), $defaults, $use_expr ); |
|
86
|
0
|
|
|
|
|
0
|
last; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
3
|
|
|
|
|
11
|
while ( $false =~ m{([\w\'\"]+)}sg ) { |
|
91
|
3
|
50
|
|
|
|
17
|
if ( $defaults->{ $1 } ) { |
|
92
|
0
|
|
|
|
|
0
|
$false = handleTemplateExpr( "cond=" . escapeQuote($false), $defaults, $use_expr ); |
|
93
|
0
|
|
|
|
|
0
|
last; |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
3
|
50
|
33
|
|
|
17
|
$true = "" if $true eq '""' || $true eq "''"; |
|
98
|
3
|
50
|
33
|
|
|
13
|
$false = "" if $false eq '""' || $false eq "''"; |
|
99
|
|
|
|
|
|
|
|
|
100
|
3
|
|
|
|
|
21
|
return "$true$false"; |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub handleTemplateExpr { |
|
104
|
244
|
|
|
244
|
0
|
486
|
my $str = shift; |
|
105
|
244
|
|
|
|
|
285
|
my $defaults = shift; |
|
106
|
244
|
|
|
|
|
249
|
my $use_expr = shift; |
|
107
|
|
|
|
|
|
|
|
|
108
|
244
|
|
|
|
|
291
|
my $ret = ""; |
|
137
|
241
|
|
|
|
|
1013
|
return $ret; |
|
138
|
|
|
|
|
|
|
} |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub handleTemplateIf { |
|
141
|
35
|
|
|
35
|
0
|
71
|
my $str = shift; |
|
142
|
35
|
|
|
|
|
46
|
my $character = shift; |
|
143
|
35
|
|
|
|
|
44
|
my $defaults = shift; |
|
144
|
35
|
|
|
|
|
39
|
my $use_expr = shift; |
|
145
|
|
|
|
|
|
|
|
|
146
|
35
|
|
|
|
|
43
|
my $ret = ""; |
|
147
|
|
|
|
|
|
|
|
|
148
|
35
|
|
|
|
|
63
|
$str =~ s/^\s+//s; |
|
149
|
35
|
|
|
|
|
77
|
$str =~ s/\s+$//s; |
|
150
|
|
|
|
|
|
|
|
|
151
|
35
|
100
|
|
|
|
78
|
if ( $str =~ m{^\!} ) { |
|
152
|
4
|
|
|
|
|
6
|
$ret = "
|
|
153
|
4
|
|
|
|
|
12
|
$str =~ s/^\!//; |
|
154
|
|
|
|
|
|
|
} |
|
155
|
|
|
|
|
|
|
else { |
|
156
|
31
|
|
|
|
|
46
|
$ret = "
|
|
157
|
|
|
|
|
|
|
} |
|
158
|
|
|
|
|
|
|
|
|
159
|
35
|
100
|
66
|
|
|
142
|
if ( !$use_expr || exists( $defaults->{ $str } ) ) { |
|
160
|
11
|
|
|
|
|
23
|
$ret .= " NAME=$character$str$character"; |
|
161
|
|
|
|
|
|
|
} |
|
162
|
|
|
|
|
|
|
else { |
|
163
|
24
|
|
|
|
|
37
|
my %words; |
|
164
|
24
|
|
|
|
|
31
|
my $hasText = 0; |
|
165
|
|
|
|
|
|
|
|
|
166
|
24
|
|
|
|
|
110
|
while ( $str =~ m{([\w\'\"]+)}sg ) { |
|
167
|
33
|
100
|
66
|
|
|
179
|
if ( $defaults->{ $1 } && $defaults->{ $1 }->{ TYPE } eq "text" ) { |
|
168
|
15
|
|
|
|
|
15
|
$hasText = 1; |
|
169
|
15
|
|
|
|
|
18
|
last; |
|
170
|
|
|
|
|
|
|
} |
|
171
|
|
|
|
|
|
|
} |
|
172
|
|
|
|
|
|
|
|
|
173
|
24
|
100
|
|
|
|
51
|
if ( $hasText ) { |
|
174
|
15
|
|
|
|
|
34
|
$str =~ s/\s*\=\=\s*/ eq /sg; |
|
175
|
15
|
|
|
|
|
28
|
$str =~ s/\s*\!\=\s*/ ne /sg; |
|
176
|
15
|
|
|
|
|
28
|
$str =~ s/\s*\<\=\>\s*/ cmp /sg; |
|
177
|
15
|
|
|
|
|
40
|
$str =~ s/\s*\>\=\s*/ ge /sg; |
|
178
|
15
|
|
|
|
|
24
|
$str =~ s/\s*\>\s*/ gt /sg; |
|
179
|
15
|
|
|
|
|
30
|
$str =~ s/\s*\<\=\s*/ le /sg; |
|
180
|
15
|
|
|
|
|
27
|
$str =~ s/\s*\<\s*/ lt /sg; |
|
181
|
|
|
|
|
|
|
} |
|
182
|
|
|
|
|
|
|
|
|
183
|
24
|
|
|
|
|
70
|
$ret .= " EXPR=$character$str$character"; |
|
184
|
|
|
|
|
|
|
} |
|
185
|
|
|
|
|
|
|
|
|
186
|
35
|
|
|
|
|
39
|
$ret .= ">"; |
|
187
|
35
|
|
|
|
|
251
|
return $ret; |
|
188
|
|
|
|
|
|
|
} |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
sub addEndifs { |
|
191
|
1
|
|
|
1
|
0
|
5
|
my $str = shift; |
|
192
|
|
|
|
|
|
|
|
|
193
|
1
|
|
|
|
|
2
|
my $begins = 0; |
|
194
|
1
|
|
|
|
|
3
|
my $ends = 0; |
|
195
|
1
|
|
|
|
|
8
|
while ( $str =~ m{
|
|
196
|
4
|
|
|
|
|
15
|
$begins++; |
|
197
|
|
|
|
|
|
|
} |
|
198
|
|
|
|
|
|
|
|
|
199
|
1
|
|
|
|
|
5
|
while ( $str =~ m{}g ) { |
|
200
|
0
|
|
|
|
|
0
|
$ends++; |
|
201
|
|
|
|
|
|
|
} |
|
202
|
|
|
|
|
|
|
|
|
203
|
1
|
|
|
|
|
13
|
$str .= ( "" x ($begins - $ends) ); |
|
204
|
|
|
|
|
|
|
} |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
sub DWT2HTML { |
|
207
|
257
|
|
|
257
|
1
|
14791
|
my $dwt = shift; |
|
208
|
257
|
|
100
|
|
|
865
|
my $force_template_expr = shift || 0; |
|
209
|
|
|
|
|
|
|
|
|
210
|
257
|
50
|
33
|
|
|
839
|
my $using_template_expr = caller(6) && caller(6) eq "HTML::Template::Expr" ? 1 : 0; |
|
211
|
257
|
|
66
|
|
|
1989
|
$using_template_expr ||= $force_template_expr; |
|
212
|
|
|
|
|
|
|
|
|
213
|
257
|
|
|
|
|
1152
|
my %params = ( "_isFirst" => {}, |
|
214
|
|
|
|
|
|
|
"_isLast" => {}, |
|
215
|
|
|
|
|
|
|
"_index" => {}, |
|
216
|
|
|
|
|
|
|
); |
|
217
|
257
|
|
|
|
|
7619
|
while ( $$dwt =~ //g ) { |
|
218
|
243
|
|
|
|
|
504
|
my $text = $1; |
|
219
|
|
|
|
|
|
|
|
|
220
|
243
|
|
|
|
|
352
|
my $name; |
|
221
|
243
|
50
|
|
|
|
2716
|
if ( $text =~ m{\s[Nn][Aa][Mm][Ee]=([\'\"])(.*?)\1} ) { |
|
222
|
243
|
|
|
|
|
575
|
$name = $2; |
|
223
|
|
|
|
|
|
|
} |
|
224
|
|
|
|
|
|
|
else { |
|
225
|
0
|
|
|
|
|
0
|
next; |
|
226
|
|
|
|
|
|
|
} |
|
227
|
|
|
|
|
|
|
|
|
228
|
243
|
|
|
|
|
287
|
my $val = ""; |
|
229
|
243
|
50
|
|
|
|
2315
|
if ( $text =~ m{\s[Vv][Aa][Ll][Uu][Ee]=([\'\"])(.*?)\1} ) { |
|
230
|
243
|
|
|
|
|
470
|
$val = $2; |
|
231
|
|
|
|
|
|
|
} |
|
232
|
|
|
|
|
|
|
# else { |
|
233
|
|
|
|
|
|
|
# next; |
|
234
|
|
|
|
|
|
|
# } |
|
235
|
|
|
|
|
|
|
|
|
236
|
243
|
|
|
|
|
598
|
my $type = ""; |
|
237
|
243
|
50
|
|
|
|
1728
|
if ( $text =~ m{\s[Tt][Yy][Pp][Ee]=([\'\"])(.*?)\1} ) { |
|
238
|
243
|
|
|
|
|
10988
|
$type = $2; |
|
239
|
|
|
|
|
|
|
} |
|
240
|
|
|
|
|
|
|
|
|
241
|
243
|
|
|
|
|
273
|
my $escape = ""; |
|
242
|
243
|
100
|
|
|
|
863
|
if ( $text =~ m{\s[Ee][Ss][Cc][Aa][Pp][Ee]=([\'\"])(.*?)\1} ) { |
|
243
|
160
|
|
|
|
|
249
|
$escape = $2; |
|
244
|
|
|
|
|
|
|
} |
|
245
|
|
|
|
|
|
|
|
|
246
|
243
|
50
|
|
|
|
857
|
if ( lc($type) eq "boolean" ) { |
|
247
|
0
|
0
|
|
|
|
0
|
$val = lc($val) eq "false" ? 1 : 0; |
|
248
|
|
|
|
|
|
|
} |
|
249
|
|
|
|
|
|
|
|
|
250
|
243
|
|
100
|
|
|
3529
|
$params{ $name } = { DEFAULT => $val || "", |
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
251
|
|
|
|
|
|
|
ESCAPE => $escape || "", |
|
252
|
|
|
|
|
|
|
TYPE => lc($type || ""), |
|
253
|
|
|
|
|
|
|
}; |
|
254
|
|
|
|
|
|
|
} |
|
255
|
|
|
|
|
|
|
|
|
256
|
257
|
|
|
|
|
3119
|
$$dwt =~ s/\@\@\(\s*_document._Get\(\s*([\'\"])(.*?)\1\s*\,\s*([\'\"])(.*?)\3\s*\)\s*\)\@\@//sg; |
|
257
|
257
|
|
|
|
|
676
|
$$dwt =~ s/\@\@\(\s*_document._Get\(\s*([\'\"])(.*?)\1\s*\)\s*\)\@\@//sg; |
|
258
|
|
|
|
|
|
|
|
|
259
|
257
|
|
|
|
|
732
|
$$dwt =~ s/_document\[([\'\"])(.*?)\1\]/$2/sg; |
|
260
|
257
|
|
|
|
|
333
|
$$dwt =~ s/_repeat\[([\'\"])(.*?)\1\]/$2/sg; |
|
261
|
257
|
|
|
|
|
1587
|
$$dwt =~ s/\s*//sg; |
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
# TemplateBeginEditable |
|
264
|
257
|
|
|
|
|
467
|
$$dwt =~ s{(.*?)}{handleTemplateEditable( $1, $2 )}esg; |
|
|
6
|
|
|
|
|
17
|
|
|
265
|
|
|
|
|
|
|
|
|
266
|
257
|
|
|
|
|
511
|
$$dwt =~ s{\@\@\((.*?)\)\@\@}{ my $var = $1; |
|
|
52
|
|
|
|
|
107
|
|
|
267
|
52
|
|
|
|
|
99
|
$var =~ s/^\s+//s; |
|
268
|
52
|
|
|
|
|
91
|
$var =~ s/\s+$//s; |
|
269
|
|
|
|
|
|
|
sprintf( "", |
|
270
|
|
|
|
|
|
|
escapeQuote($var), |
|
271
|
52
|
100
|
100
|
|
|
98
|
$params{$var} && $params{$var}->{ ESCAPE } ? " ESCAPE='$params{$var}->{ ESCAPE}'" : "", |
|
272
|
|
|
|
|
|
|
) |
|
273
|
|
|
|
|
|
|
}esg; |
|
274
|
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
# TemplateExpr |
|
276
|
257
|
|
|
|
|
2087
|
$$dwt =~ s{}{handleTemplateExpr($1, \%params, $using_template_expr)}esg; |
|
|
244
|
|
|
|
|
674
|
|
|
277
|
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
# TemplateBeginIf Cond= |
|
279
|
257
|
|
|
|
|
1704
|
$$dwt =~ s{}{handleTemplateIf($2, $1, \%params, $using_template_expr )}esg; |
|
|
18
|
|
|
|
|
39
|
|
|
280
|
|
|
|
|
|
|
# TemplateEndIf |
|
281
|
257
|
|
|
|
|
745
|
$$dwt =~ s{}{}sg; |
|
282
|
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
# IgnoreTemplateBeginIf Cond= NOTE: this is not a real dreamweaver tag, but we need it because dreamweaver doesn't |
|
284
|
|
|
|
|
|
|
# like to have TemplateBeginIf tags before the tag |
|
285
|
257
|
|
|
|
|
2200
|
$$dwt =~ s{}{handleTemplateIf($2, $1, \%params, $using_template_expr )}esg; |
|
|
13
|
|
|
|
|
31
|
|
|
286
|
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
# IgnoreTemplateEndIf NOTE: Like the IgnoreTemplateBeginIf tag, this tag is not a real dreamweaver tag |
|
288
|
257
|
|
|
|
|
616
|
$$dwt =~ s{}{}sg; |
|
289
|
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
# TemplateBeginMultipleIf |
|
291
|
257
|
|
|
|
|
511
|
$$dwt =~ s{}{}sg; |
|
292
|
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
# TemplateEndMultipleIf |
|
294
|
257
|
|
|
|
|
1031
|
$$dwt =~ s{}{}sg; |
|
295
|
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
# TemplateBeginIfClause Cond= |
|
297
|
257
|
|
|
|
|
503
|
$$dwt =~ s{}{handleTemplateIf($2, $1, \%params, $using_template_expr )}esg; |
|
|
4
|
|
|
|
|
12
|
|
|
298
|
257
|
|
|
|
|
528
|
$$dwt =~ s{}{}sg; |
|
299
|
|
|
|
|
|
|
|
|
300
|
257
|
|
|
|
|
697
|
while ( $$dwt =~ m{((?:(?!).)*)}s ) { |
|
301
|
1
|
|
|
|
|
104
|
$$dwt =~ s{(((?!).)*)}{addEndifs($1)}se; |
|
|
1
|
|
|
|
|
5
|
|
|
302
|
|
|
|
|
|
|
} |
|
303
|
|
|
|
|
|
|
|
|
304
|
257
|
|
|
|
|
916
|
while ( $$dwt =~ m{
|
|
305
|
34
|
|
|
|
|
575
|
$$dwt =~ s{} |
|
306
|
35
|
100
|
|
|
|
644
|
{"" : "")}seg; |
|
307
|
|
|
|
|
|
|
} |
|
308
|
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
|
|
310
|
257
|
|
|
|
|
656
|
$$dwt =~ s{
|
|
311
|
257
|
|
|
|
|
349
|
$$dwt =~ s{
|
|
312
|
257
|
|
|
|
|
419
|
$$dwt =~ s{
|
|
313
|
257
|
|
|
|
|
352
|
$$dwt =~ s{<\!\-\- TMPL_(\w*) NAME=([\"\'])_isFirst\2}{}{}sg; |
|
319
|
|
|
|
|
|
|
# TemplateEndRepeat Name= |
|
320
|
257
|
|
|
|
|
1519
|
$$dwt =~ s{}{}sg; |
|
321
|
|
|
|
|
|
|
} |
|
322
|
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
sub DWT2HTMLExpr { |
|
324
|
130
|
|
|
130
|
1
|
29692
|
DWT2HTML( shift, 1 ); |
|
325
|
|
|
|
|
|
|
} |
|
326
|
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
1; |
|
329
|
|
|
|
|
|
|
__END__ |