|
Lines 303-308
sub _parametrize_internal{
Link Here
|
| 303 |
return $t; |
303 |
return $t; |
| 304 |
} |
304 |
} |
| 305 |
|
305 |
|
|
|
306 |
sub trimmable_string { |
| 307 |
my $s = shift; |
| 308 |
|
| 309 |
# Remove TT start and end tag |
| 310 |
$s =~ s/^\[%[-+]?\s+//; |
| 311 |
$s =~ s/\s+[-+]?%\]$//; |
| 312 |
|
| 313 |
return 1 if ($s =~ /^#/); # comment |
| 314 |
|
| 315 |
# semicolon or newline is a TT directive separator. |
| 316 |
if ($s =~ /[;\n]/) { |
| 317 |
my @parts = split(/[;\n]/, $s); |
| 318 |
foreach my $tmps (@parts) { |
| 319 |
return 0 if (!trimmable_string($tmps)); |
| 320 |
} |
| 321 |
return 1; |
| 322 |
} |
| 323 |
|
| 324 |
# trim away spaces |
| 325 |
$s =~ s/^\s+//; |
| 326 |
$s =~ s/\s+$//; |
| 327 |
|
| 328 |
if ($s =~ /^IF / || |
| 329 |
$s =~ /^ELSIF / || |
| 330 |
$s =~ /^ELSE\b/ || |
| 331 |
$s =~ /^END\b/ || |
| 332 |
$s =~ /^INCLUDE / || |
| 333 |
$s =~ /^PROCESS / || |
| 334 |
$s =~ /^BLOCK / || |
| 335 |
$s =~ /^SWITCH / || |
| 336 |
$s =~ /^CASE\b/ || |
| 337 |
$s =~ /^SET / || |
| 338 |
$s =~ /^FILTER / || |
| 339 |
$s =~ /^FOREACH / || |
| 340 |
$s =~ /^FOR / || |
| 341 |
$s =~ /^USE / || |
| 342 |
$s =~ /^UNLESS / || |
| 343 |
$s =~ /^\S+ *= *\S/ # variable = value |
| 344 |
) { |
| 345 |
return 1; |
| 346 |
} |
| 347 |
return 0; |
| 348 |
} |
| 349 |
|
| 350 |
sub trimmable { |
| 351 |
my $t = shift; |
| 352 |
return 0 if (!$t || $t->type != C4::TmplTokenType::DIRECTIVE); |
| 353 |
return trimmable_string($t->string); |
| 354 |
} |
| 355 |
|
| 306 |
sub next_token { |
356 |
sub next_token { |
| 307 |
my $self = shift; |
357 |
my $self = shift; |
| 308 |
my $next; |
358 |
my $next; |
|
Lines 326-332
sub next_token {
Link Here
|
| 326 |
} |
376 |
} |
| 327 |
# elsif( $next->type == C4::TmplTokenType::DIRECTIVE && $next->string =~ m/\[%\s*\w+\s*%\]/ ){ |
377 |
# elsif( $next->type == C4::TmplTokenType::DIRECTIVE && $next->string =~ m/\[%\s*\w+\s*%\]/ ){ |
| 328 |
elsif( $next->type == C4::TmplTokenType::DIRECTIVE ){ |
378 |
elsif( $next->type == C4::TmplTokenType::DIRECTIVE ){ |
| 329 |
push @parts, $next; |
379 |
if (trimmable($next)) { |
|
|
380 |
return $next unless @parts; |
| 381 |
$self->{_parser}->unshift_token($next); |
| 382 |
return $self->_parametrize_internal(@parts); |
| 383 |
} else { |
| 384 |
push @parts, $next; |
| 385 |
} |
| 330 |
} |
386 |
} |
| 331 |
elsif ( $next->type == C4::TmplTokenType::CDATA){ |
387 |
elsif ( $next->type == C4::TmplTokenType::CDATA){ |
| 332 |
$self->_set_js_mode(1); |
388 |
$self->_set_js_mode(1); |
| 333 |
- |
|
|