Andy Wardley wrote:
Hi Barry,
The first problem is that the patch, when applied, generates the following
warning each time it is evaluated:
Useless use of string eq in void context at lib/Template/Parser.pm line 325
Hmmm, missed that; sorry. Removing another line fixes it :).
The second problem is that I'm not entirely sure what the bug is and
how the patch fixes it.
The bug is that Template::Parser miscounts the line numbers and ends up
reporting errors from the wrong line within the template (or, in my
case, using caller() from within a custom vmethod).
Run this through tpage; without the patch, the error is reported on line
3, with it the error is reported on line 2. If you have more [%- ... %]
tags before the END tag, the offset grows worse.
[%- 1 -%]
[%- END %]
The patch may not fix all such errors, but so far I haven't found any
others.
- Barrie
--- c:\.cpan\build\Template-Toolkit-2.14\lib\Template\Parser.pm 2004-10-04
06:27:39.000000000 -0400
+++ lib\Template\Parser.pm 2006-01-05 15:37:41.843750000 -0500
@@ -324,9 +324,7 @@
? ' ' : '';
# chomp off whitespace and newline preceding directive
- $chomp and $pre =~ s/(\n|^)([ \t]*)\Z/($1||$2) ? $space : ''/me
- and $1 eq "\n"
- and $prelines++;
+ $chomp and $pre =~ s/(\n|^)([ \t]*)\Z/($1||$2) ? $space :
''/me;
}
# remove trailing whitespace and check for a '-' chomp flag
@@ -350,8 +348,8 @@
push(@tokens, $interp
? [ $pre, $line, 'ITEXT' ]
: ('TEXT', $pre) );
- $line += $prelines;
}
+ $line += $prelines;
# and now the directive, along with line number information
if (length $dir) {