| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# |
|
2
|
|
|
|
|
|
|
# (c) Jan Gehring |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Rex::Template::NG; |
|
6
|
|
|
|
|
|
|
|
|
7
|
10
|
|
|
10
|
|
70251
|
use v5.12.5; |
|
|
10
|
|
|
|
|
71
|
|
|
8
|
10
|
|
|
10
|
|
83
|
use warnings; |
|
|
10
|
|
|
|
|
58
|
|
|
|
10
|
|
|
|
|
5652
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '1.14.2.3'; # TRIAL VERSION |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
|
13
|
1
|
|
|
1
|
0
|
130
|
my $that = shift; |
|
14
|
1
|
|
33
|
|
|
7
|
my $proto = ref($that) || $that; |
|
15
|
1
|
|
|
|
|
3
|
my $self = {@_}; |
|
16
|
|
|
|
|
|
|
|
|
17
|
1
|
|
|
|
|
3
|
bless( $self, $proto ); |
|
18
|
|
|
|
|
|
|
|
|
19
|
1
|
|
|
|
|
4
|
$self->_init(); |
|
20
|
|
|
|
|
|
|
|
|
21
|
1
|
|
|
|
|
3
|
return $self; |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub _init { |
|
25
|
15
|
|
|
15
|
|
33
|
my ($self) = @_; |
|
26
|
|
|
|
|
|
|
|
|
27
|
15
|
|
|
|
|
29
|
$self->{__output__} = ""; |
|
28
|
15
|
|
|
|
|
21
|
$self->{__code__} = ""; |
|
29
|
15
|
|
|
|
|
31
|
$self->{__raw_data__} = ""; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub parse { |
|
33
|
14
|
|
|
14
|
0
|
32
|
my $self = shift; |
|
34
|
14
|
|
|
|
|
24
|
my $c = shift; |
|
35
|
14
|
|
|
|
|
21
|
my %in_vars; |
|
36
|
|
|
|
|
|
|
|
|
37
|
14
|
|
|
|
|
74
|
$self->_init(); |
|
38
|
|
|
|
|
|
|
|
|
39
|
14
|
100
|
|
|
|
69
|
if ( ref $_[0] eq "HASH" ) { |
|
40
|
11
|
|
|
|
|
14
|
%in_vars = %{ +shift }; |
|
|
11
|
|
|
|
|
41
|
|
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
else { |
|
43
|
3
|
|
|
|
|
9
|
%in_vars = @_; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
14
|
|
|
|
|
21
|
my %vars; |
|
47
|
|
|
|
|
|
|
|
|
48
|
14
|
|
|
|
|
35
|
for my $key ( keys %in_vars ) { |
|
49
|
12
|
|
|
|
|
22
|
my $new_key = $key; |
|
50
|
12
|
|
|
|
|
37
|
$new_key =~ s/[^a-zA-Z0-9_]/_/gms; |
|
51
|
12
|
|
|
|
|
36
|
$vars{$new_key} = $in_vars{$key}; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# some backward compat. to old template module. |
|
55
|
14
|
|
|
|
|
70
|
$c =~ s/\$::([a-zA-Z0-9_]+)/_replace_var($1, \%vars)/egms; |
|
|
9
|
|
|
|
|
27
|
|
|
56
|
|
|
|
|
|
|
|
|
57
|
14
|
|
|
|
|
33
|
my $code = ""; |
|
58
|
|
|
|
|
|
|
|
|
59
|
14
|
|
|
|
|
22
|
my $var_data = ' |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
return sub { |
|
62
|
|
|
|
|
|
|
my ( |
|
63
|
|
|
|
|
|
|
$self, |
|
64
|
|
|
|
|
|
|
'; |
|
65
|
|
|
|
|
|
|
|
|
66
|
14
|
|
|
|
|
21
|
my @code_values; |
|
67
|
14
|
|
|
|
|
32
|
for my $var ( keys %vars ) { |
|
68
|
12
|
|
|
|
|
26
|
$var_data .= '$' . $var . ", \n"; |
|
69
|
12
|
|
|
|
|
29
|
push( @code_values, $vars{$var} ); |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
14
|
|
|
|
|
28
|
$var_data .= '$this_is_really_nothing) = @_;'; |
|
73
|
14
|
|
|
|
|
20
|
$var_data .= "\n"; |
|
74
|
|
|
|
|
|
|
|
|
75
|
14
|
|
|
|
|
18
|
$code = $var_data; |
|
76
|
|
|
|
|
|
|
|
|
77
|
14
|
|
|
|
|
33
|
$code .= $self->_parse($c); |
|
78
|
|
|
|
|
|
|
|
|
79
|
14
|
|
|
|
|
25
|
$code .= "\n}"; |
|
80
|
|
|
|
|
|
|
|
|
81
|
14
|
|
|
|
|
20
|
my $idx_c = 1; |
|
82
|
14
|
|
|
|
|
68
|
for my $l ( split( /\n/, $code ) ) { |
|
83
|
232
|
|
|
|
|
282
|
$idx_c++; |
|
84
|
232
|
|
100
|
|
|
431
|
$l ||= ""; |
|
85
|
232
|
|
|
|
|
494
|
Rex::Logger::debug("$idx_c. $l"); |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
14
|
|
|
|
|
38
|
$self->{__code__} = $code; |
|
89
|
14
|
|
|
|
|
26
|
$self->{__raw_data__} = $c; |
|
90
|
|
|
|
|
|
|
|
|
91
|
10
|
|
|
10
|
|
98
|
no warnings; |
|
|
10
|
|
|
|
|
49
|
|
|
|
10
|
|
|
|
|
1063
|
|
|
92
|
14
|
|
|
|
|
1857
|
my $tpl_code = eval($code); |
|
93
|
10
|
|
|
10
|
|
91
|
use warnings; |
|
|
10
|
|
|
|
|
58
|
|
|
|
10
|
|
|
|
|
13905
|
|
|
94
|
|
|
|
|
|
|
|
|
95
|
14
|
50
|
|
|
|
50
|
if ($@) { |
|
96
|
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
0
|
my $error = $@; |
|
98
|
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
0
|
my ($error_line) = ( $error =~ m/line (\d+)[\.,]/ ); |
|
100
|
0
|
|
|
|
|
0
|
my @code_lines = split( /\n/, $code ); |
|
101
|
0
|
|
|
|
|
0
|
my @raw_lines = split( /\n/, $c ); |
|
102
|
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
0
|
my $idx = $error_line - 5; |
|
104
|
0
|
|
|
|
|
0
|
for my $l ( @code_lines[ $error_line - 5 .. $error_line + 5 ] ) { |
|
105
|
0
|
|
|
|
|
0
|
$idx++; |
|
106
|
0
|
|
0
|
|
|
0
|
$l ||= ""; |
|
107
|
0
|
|
|
|
|
0
|
Rex::Logger::debug("$idx. $l"); |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
0
|
my $template_line = 0; |
|
111
|
0
|
|
|
|
|
0
|
my $add_to_error_line = -1; |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
# search the error line |
|
114
|
0
|
|
|
|
|
0
|
Rex::Logger::debug("Template-Error-Line: $error_line"); |
|
115
|
0
|
|
|
|
|
0
|
for ( my $bi = $error_line - 1 ; $bi >= 0 ; $bi-- ) { |
|
116
|
0
|
0
|
|
|
|
0
|
if ( $code_lines[$bi] =~ m/^# LINE: (\d+)$/ ) { |
|
117
|
0
|
|
|
|
|
0
|
$template_line = $1 + $add_to_error_line; |
|
118
|
0
|
|
|
|
|
0
|
last; |
|
119
|
|
|
|
|
|
|
} |
|
120
|
0
|
|
|
|
|
0
|
$add_to_error_line++; |
|
121
|
|
|
|
|
|
|
} |
|
122
|
|
|
|
|
|
|
|
|
123
|
0
|
0
|
|
|
|
0
|
if ( !$template_line ) { |
|
124
|
0
|
|
|
|
|
0
|
die "Uncatchable error in template: $error ($error_line)"; |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
|
|
127
|
0
|
|
|
|
|
0
|
my $start_part = $template_line - 5; |
|
128
|
0
|
0
|
|
|
|
0
|
$start_part = 0 if $start_part <= 0; |
|
129
|
0
|
|
|
|
|
0
|
my $end_part = $template_line + 5; |
|
130
|
0
|
0
|
|
|
|
0
|
$end_part = scalar @raw_lines if $end_part > scalar @raw_lines; |
|
131
|
|
|
|
|
|
|
|
|
132
|
0
|
|
|
|
|
0
|
my $idx_t = $start_part; |
|
133
|
|
|
|
|
|
|
|
|
134
|
0
|
|
|
|
|
0
|
for my $l ( @raw_lines[ $start_part .. $end_part ] ) { |
|
135
|
0
|
|
|
|
|
0
|
$idx_t++; |
|
136
|
0
|
|
0
|
|
|
0
|
$l ||= ""; |
|
137
|
0
|
|
|
|
|
0
|
Rex::Logger::info("$idx_t. $l"); |
|
138
|
|
|
|
|
|
|
} |
|
139
|
|
|
|
|
|
|
|
|
140
|
0
|
|
|
|
|
0
|
my $tpl_error = $error; |
|
141
|
0
|
|
|
|
|
0
|
$tpl_error =~ s/at \(eval \d+\) line \d+/at template line $template_line/; |
|
142
|
|
|
|
|
|
|
|
|
143
|
0
|
0
|
0
|
|
|
0
|
if ( $error =~ m/Global symbol "([^"]+)" requires explicit package name/ ) { |
|
|
|
0
|
|
|
|
|
|
|
144
|
0
|
|
|
|
|
0
|
$tpl_error = |
|
145
|
|
|
|
|
|
|
"Unknown variable name $1 in code line: ,,$raw_lines[$template_line-1]'' line: $template_line.\nOriginal Error:\n$error\n"; |
|
146
|
|
|
|
|
|
|
} |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
# internal parsing error, maybe runaway line without ";" |
|
149
|
|
|
|
|
|
|
elsif ( $raw_lines[ $template_line - 2 ] =~ m/^%/ |
|
150
|
|
|
|
|
|
|
&& $raw_lines[ $template_line - 2 ] !~ m/[;{("']/ ) |
|
151
|
|
|
|
|
|
|
{ |
|
152
|
0
|
|
|
|
|
0
|
Rex::Logger::debug( |
|
153
|
|
|
|
|
|
|
"Template Error in compiled line: $code_lines[$error_line-1]"); |
|
154
|
0
|
|
|
|
|
0
|
Rex::Logger::info( |
|
155
|
|
|
|
|
|
|
"Template Error somewhere around: $raw_lines[$template_line-2]", |
|
156
|
|
|
|
|
|
|
"error" ); |
|
157
|
|
|
|
|
|
|
|
|
158
|
0
|
|
|
|
|
0
|
my $template_line_ = $template_line - 1; |
|
159
|
0
|
|
|
|
|
0
|
$tpl_error = |
|
160
|
|
|
|
|
|
|
"Maybe missing <<;, {, (, \" or '>> in code line: ,,$raw_lines[$template_line-2]'' line $template_line_.\nOriginal Error:\n$error\n"; |
|
161
|
|
|
|
|
|
|
} |
|
162
|
|
|
|
|
|
|
else { |
|
163
|
0
|
|
|
|
|
0
|
$tpl_error = |
|
164
|
|
|
|
|
|
|
"Failed parsing template. Unkown error near $template_line.\nOriginal Error:\n$error\n"; |
|
165
|
|
|
|
|
|
|
} |
|
166
|
|
|
|
|
|
|
|
|
167
|
0
|
|
|
|
|
0
|
die $tpl_error; |
|
168
|
|
|
|
|
|
|
} |
|
169
|
|
|
|
|
|
|
|
|
170
|
14
|
|
|
|
|
269
|
$tpl_code->( $self, @code_values ); |
|
171
|
|
|
|
|
|
|
|
|
172
|
14
|
|
|
|
|
234
|
return $self->{__output__}; |
|
173
|
|
|
|
|
|
|
} |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
sub __out { |
|
176
|
44
|
|
|
44
|
|
88
|
my ( $self, $str ) = @_; |
|
177
|
|
|
|
|
|
|
|
|
178
|
44
|
50
|
|
|
|
572
|
$self->{__output__} .= defined $str ? $str : ""; |
|
179
|
|
|
|
|
|
|
} |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
sub _parse { |
|
182
|
14
|
|
|
14
|
|
29
|
my ( $self, $c ) = @_; |
|
183
|
|
|
|
|
|
|
|
|
184
|
14
|
|
|
|
|
22
|
my $parsed = ""; |
|
185
|
|
|
|
|
|
|
|
|
186
|
14
|
|
|
|
|
92
|
my @chars = split( //, $c ); |
|
187
|
|
|
|
|
|
|
|
|
188
|
14
|
|
|
|
|
25
|
my $begin_line = 0; |
|
189
|
14
|
|
|
|
|
20
|
my $code_line = 0; |
|
190
|
14
|
|
|
|
|
22
|
my $code_block = 0; |
|
191
|
14
|
|
|
|
|
19
|
my $code_block_output = 0; |
|
192
|
14
|
|
|
|
|
17
|
my $current_char_idx = -1; |
|
193
|
14
|
|
|
|
|
18
|
my $line_count = 1; |
|
194
|
14
|
|
|
|
|
21
|
my $string_open = 0; |
|
195
|
14
|
|
|
|
|
17
|
my $skip_next = 0; |
|
196
|
14
|
|
|
|
|
18
|
my $skip_next_newline = 0; |
|
197
|
|
|
|
|
|
|
|
|
198
|
14
|
|
|
|
|
26
|
for my $curr_char (@chars) { |
|
199
|
427
|
|
|
|
|
489
|
$current_char_idx++; |
|
200
|
|
|
|
|
|
|
|
|
201
|
427
|
100
|
|
|
|
715
|
if ($skip_next) { |
|
202
|
10
|
|
|
|
|
13
|
$skip_next = 0; |
|
203
|
10
|
|
|
|
|
20
|
next; |
|
204
|
|
|
|
|
|
|
} |
|
205
|
|
|
|
|
|
|
|
|
206
|
417
|
|
100
|
|
|
740
|
my $prev_char = $chars[ $current_char_idx - 1 ] || ""; |
|
207
|
417
|
|
100
|
|
|
734
|
my $next_char = $chars[ $current_char_idx + 1 ] || ""; |
|
208
|
|
|
|
|
|
|
|
|
209
|
417
|
50
|
33
|
|
|
681
|
if ( $skip_next_newline && $curr_char eq "\n" ) { |
|
210
|
0
|
|
|
|
|
0
|
$skip_next_newline = 0; |
|
211
|
0
|
|
|
|
|
0
|
$curr_char = ""; |
|
212
|
|
|
|
|
|
|
} |
|
213
|
|
|
|
|
|
|
|
|
214
|
417
|
100
|
66
|
|
|
734
|
if ( $curr_char eq "\n" && $prev_char ne "\n" ) { # count lines, for error messages |
|
215
|
10
|
|
|
|
|
15
|
$line_count++; |
|
216
|
10
|
|
|
|
|
15
|
$parsed .= $curr_char; |
|
217
|
|
|
|
|
|
|
|
|
218
|
10
|
50
|
|
|
|
19
|
if ($string_open) { |
|
219
|
10
|
|
|
|
|
14
|
$parsed .= "});\n"; |
|
220
|
|
|
|
|
|
|
} |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
# reset vars |
|
223
|
10
|
|
|
|
|
10
|
$code_line = 0; |
|
224
|
10
|
|
|
|
|
13
|
$string_open = 0; |
|
225
|
|
|
|
|
|
|
|
|
226
|
10
|
|
|
|
|
18
|
next; |
|
227
|
|
|
|
|
|
|
} |
|
228
|
|
|
|
|
|
|
|
|
229
|
407
|
50
|
33
|
|
|
676
|
if ( $curr_char eq "\n" && $prev_char eq "\n" ) { |
|
230
|
0
|
|
|
|
|
0
|
$parsed .= "\$self->__out(q{\n});\n"; |
|
231
|
0
|
|
|
|
|
0
|
$line_count++; |
|
232
|
0
|
|
|
|
|
0
|
next; |
|
233
|
|
|
|
|
|
|
} |
|
234
|
|
|
|
|
|
|
|
|
235
|
407
|
0
|
33
|
|
|
681
|
if ( $curr_char eq "-" |
|
|
|
|
0
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
236
|
|
|
|
|
|
|
&& $next_char eq "%" |
|
237
|
|
|
|
|
|
|
&& ( $prev_char eq " " || $prev_char eq "\n" ) |
|
238
|
|
|
|
|
|
|
&& $chars[ $current_char_idx + 2 ] eq ">" ) |
|
239
|
|
|
|
|
|
|
{ |
|
240
|
|
|
|
|
|
|
# skip "-" of -%> sequence |
|
241
|
0
|
|
|
|
|
0
|
$skip_next_newline = 1; |
|
242
|
0
|
|
|
|
|
0
|
next; |
|
243
|
|
|
|
|
|
|
} |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
# catch code line |
|
246
|
|
|
|
|
|
|
# % some code |
|
247
|
407
|
50
|
100
|
|
|
1143
|
if ( |
|
|
|
|
100
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
248
|
|
|
|
|
|
|
!$code_block |
|
249
|
|
|
|
|
|
|
&& ( $prev_char eq "\n" |
|
250
|
|
|
|
|
|
|
|| $current_char_idx == 0 ) # first line or new line |
|
251
|
|
|
|
|
|
|
&& $curr_char eq "%" |
|
252
|
|
|
|
|
|
|
&& $next_char eq " " # code block, and no % char escape sequence |
|
253
|
|
|
|
|
|
|
) |
|
254
|
|
|
|
|
|
|
{ |
|
255
|
0
|
|
|
|
|
0
|
$code_line = 1; |
|
256
|
0
|
|
|
|
|
0
|
$parsed .= "\n# LINE: $line_count\n"; |
|
257
|
0
|
|
|
|
|
0
|
next; |
|
258
|
|
|
|
|
|
|
} |
|
259
|
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
# catch '<% ' ... |
|
261
|
407
|
100
|
66
|
|
|
735
|
if ( $prev_char eq "<" |
|
|
|
|
66
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
262
|
|
|
|
|
|
|
&& $curr_char eq "%" |
|
263
|
|
|
|
|
|
|
&& ( $next_char eq " " || $next_char eq "\n" ) ) |
|
264
|
|
|
|
|
|
|
{ |
|
265
|
6
|
|
|
|
|
11
|
$code_block = 1; |
|
266
|
6
|
50
|
|
|
|
14
|
if ($string_open) { |
|
267
|
6
|
|
|
|
|
10
|
$parsed .= "});\n"; |
|
268
|
6
|
|
|
|
|
7
|
$string_open = 0; |
|
269
|
|
|
|
|
|
|
} |
|
270
|
|
|
|
|
|
|
|
|
271
|
6
|
|
|
|
|
11
|
$parsed .= "\n# LINE: $line_count\n"; |
|
272
|
|
|
|
|
|
|
|
|
273
|
6
|
|
|
|
|
10
|
next; |
|
274
|
|
|
|
|
|
|
} |
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
# catch ' %>' |
|
277
|
401
|
100
|
66
|
|
|
1116
|
if ( |
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
278
|
|
|
|
|
|
|
$code_block |
|
279
|
|
|
|
|
|
|
&& ( ( $code_block_output || $prev_char eq " " ) |
|
280
|
|
|
|
|
|
|
|| $prev_char eq "\n" |
|
281
|
|
|
|
|
|
|
|| $prev_char eq "-" ) |
|
282
|
|
|
|
|
|
|
&& $curr_char eq "%" |
|
283
|
|
|
|
|
|
|
&& $next_char eq ">" |
|
284
|
|
|
|
|
|
|
) |
|
285
|
|
|
|
|
|
|
{ |
|
286
|
16
|
|
|
|
|
23
|
$code_block = 0; |
|
287
|
|
|
|
|
|
|
|
|
288
|
16
|
100
|
|
|
|
29
|
if ($code_block_output) { |
|
289
|
10
|
|
|
|
|
16
|
$parsed .= ");\n"; |
|
290
|
10
|
|
|
|
|
13
|
$code_block_output = 0; |
|
291
|
|
|
|
|
|
|
} |
|
292
|
|
|
|
|
|
|
|
|
293
|
16
|
|
|
|
|
22
|
$string_open = 1; |
|
294
|
16
|
|
|
|
|
25
|
$parsed .= "\n\$self->__out(q{"; |
|
295
|
|
|
|
|
|
|
|
|
296
|
16
|
|
|
|
|
28
|
next; |
|
297
|
|
|
|
|
|
|
} |
|
298
|
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
# catch '<%=' |
|
300
|
385
|
50
|
66
|
|
|
697
|
if ( $prev_char eq "<" && $curr_char eq "%" && $next_char eq "=" ) { |
|
|
|
|
66
|
|
|
|
|
|
301
|
10
|
|
|
|
|
13
|
$code_block = 1; |
|
302
|
10
|
|
|
|
|
17
|
$code_block_output = 1; |
|
303
|
|
|
|
|
|
|
|
|
304
|
10
|
50
|
|
|
|
18
|
if ($string_open) { |
|
305
|
10
|
|
|
|
|
17
|
$parsed .= "});\n"; |
|
306
|
|
|
|
|
|
|
} |
|
307
|
|
|
|
|
|
|
|
|
308
|
10
|
|
|
|
|
21
|
$parsed .= "\n# LINE: $line_count\n"; |
|
309
|
10
|
|
|
|
|
16
|
$parsed .= "\$self->__out("; |
|
310
|
10
|
|
|
|
|
11
|
$skip_next = 1; |
|
311
|
|
|
|
|
|
|
|
|
312
|
10
|
|
|
|
|
17
|
next; |
|
313
|
|
|
|
|
|
|
} |
|
314
|
|
|
|
|
|
|
|
|
315
|
375
|
100
|
66
|
|
|
887
|
if ( $code_line || $code_block ) { |
|
316
|
150
|
|
|
|
|
191
|
$parsed .= $curr_char; |
|
317
|
150
|
|
|
|
|
206
|
next; |
|
318
|
|
|
|
|
|
|
} |
|
319
|
|
|
|
|
|
|
|
|
320
|
225
|
100
|
|
|
|
347
|
if ( !$string_open ) { |
|
321
|
24
|
|
|
|
|
31
|
$string_open = 1; |
|
322
|
24
|
|
|
|
|
46
|
$parsed .= '$self->__out(q{'; |
|
323
|
|
|
|
|
|
|
} |
|
324
|
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
# don't catch opening < |
|
326
|
225
|
100
|
66
|
|
|
406
|
if ( $curr_char eq "<" && $next_char eq "%" ) { |
|
327
|
16
|
|
|
|
|
27
|
next; |
|
328
|
|
|
|
|
|
|
} |
|
329
|
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
# don't catch closing > |
|
331
|
209
|
100
|
66
|
|
|
368
|
if ( $curr_char eq ">" && $prev_char eq "%" ) { |
|
332
|
16
|
|
|
|
|
22
|
next; |
|
333
|
|
|
|
|
|
|
} |
|
334
|
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
# escaping of % sign |
|
336
|
193
|
50
|
33
|
|
|
316
|
if ( $curr_char eq "%" && $prev_char eq "%" ) { |
|
337
|
0
|
|
|
|
|
0
|
next; |
|
338
|
|
|
|
|
|
|
} |
|
339
|
|
|
|
|
|
|
|
|
340
|
193
|
100
|
|
|
|
395
|
$parsed .= $curr_char =~ m/[{}]/ ? "\\$curr_char" : $curr_char; |
|
341
|
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
} |
|
343
|
|
|
|
|
|
|
|
|
344
|
14
|
50
|
|
|
|
29
|
if ($string_open) { |
|
345
|
14
|
|
|
|
|
19
|
$parsed .= "});\n"; |
|
346
|
|
|
|
|
|
|
} |
|
347
|
|
|
|
|
|
|
|
|
348
|
14
|
|
|
|
|
68
|
return $parsed; |
|
349
|
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
} |
|
351
|
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
sub _replace_var { |
|
353
|
9
|
|
|
9
|
|
25
|
my ( $var, $t_vars ) = @_; |
|
354
|
|
|
|
|
|
|
|
|
355
|
9
|
50
|
|
|
|
25
|
if ( exists $t_vars->{$var} ) { |
|
356
|
9
|
|
|
|
|
39
|
return '$' . $var; |
|
357
|
|
|
|
|
|
|
} |
|
358
|
|
|
|
|
|
|
else { |
|
359
|
0
|
|
|
|
|
|
return '$::' . $var; |
|
360
|
|
|
|
|
|
|
} |
|
361
|
|
|
|
|
|
|
} |
|
362
|
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
1; |
|
364
|
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
__END__ |