abw / Template2

Perl Template Toolkit v2
http://template-toolkit.org/
146 stars 94 forks source link

Compiled templates have incorrect line numbers for IF statements #306

Open petdance opened 1 year ago

petdance commented 1 year ago

The line numbers in the compiled cache files aren't correct.

For this template:

[% x = 3 %]
[% y = 3 %]
[% IF x == y %]
    blah blah
[% END %]

the relevant part of the compiled Perl code is:

    eval { BLOCK: {
#line 1 "./sample.ttml"
$stash->set('x', 3);
$output .=  '
';
#line 2 "./sample.ttml"
$stash->set('y', 3);
$output .=  '
';
#line 5 "./sample.ttml"
if ($stash->get('x') eq $stash->get('y')) {
$output .=  '
    blah blah
';
}

It shows that the IF statement is on line 5, which is actually the line number of the end of the IF block.