Hi Sam and others, One problem I have encountered frequently enough to be annoying (but not enough to do anything about) was that ocassionally the line numbers of a TMPL error, didn't match up with the line that the error occurred on. As a result of my work on making H::T support custom TMPL_xxxx tag definitions, I came across this bug as it become rather blatent, and thus have found the solution for it.
On line 2259/2260 H::T implements: pop(@fstack), (*fname, *fcounter, *fmax) = \ ( @{$fstack[$#fstack]} ) if ($fcounter > $fmax); The implementation of TMPL_INCLUDE essentially inserts the included files' text at the current point of the statement, thus any text after the TMPL_INCLUDE (before the next 'chunk'), is essentially appended to the end of the included text. This code suffers the problem that if a TMPL_INCLUDE is referenced near the end of a template file, then it doesn't correctly unroll the @fstack, thus it: - incorrectly handles the end of the previous file -> as the previous file ends up with the wrong line number - doesn't unroll more than one included file (thus each previous file will also end up with the wrong line number, as well) - it is possible to hit a max include limit (ie TMPL_INCLUDE's > max_includes), due to the mis-handling of the end of the included template file(s). The solution to this is to take into account the number of '\n's introduced by the appending of the text before the next chunk. The code should read: while ($fcounter > $fmax) { my $counter_offset = $fcounter - $fmax; pop(@fstack), (*fname, *fcounter, *fmax) = \ ( @{$fstack[$#fstack]} ); $fcounter += $counter_offset; } cheers, Mathew PS. I was able to find this error by adding a support to H::T for an 'includes_debug' option (ie. I added this option and the following code around line 2208). Which if set, the following code gets executed: if ($options->{includes_debug}) { require 'Data/Dumper.pm'; print STDERR "TMPL_INCLUDE stack: ", Data::Dumper::Dumper([EMAIL PROTECTED]); } ie: I think this would be a useful addition to compliment the existing debug options. ------------------------------------------------------- SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now! http://ads.osdn.com/?ad_id56&alloc_id438&op=click _______________________________________________ Html-template-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/html-template-users