Bill Moseley wrote:
Then after correcting the syntax error I get:

TT produced an error:
[file error - one: not found]

Hi Bill,

Add this line to Template::Parser in the parse() method.

+++ Parser.pm   2006-07-31 10:00:54.000000000 +0100
@@ -244,6 +244,7 @@
# store for blocks defined in the template (see define_block())
     my $defblock = $self->{ DEFBLOCK } = { };
     my $metadata = $self->{ METADATA } = [ ];
+    $self->{ DEFBLOCKS } = [ ];

(sorry if my dumb-ass mailer has screwed up the formatting -
Thunderbird is far prettier than mutt, but *please* give me a decent
text editor!)

The problem only occurs if the syntax error is inside a block.  The
parser, on encountering a BLOCK, pushes the name onto
$self->{ DEFBLOCKS } and pops it off again when it sees the END.

This way, it can correctly identify the inner block defined below
as 'foo/bar'

   [% BLOCK foo %]
      ...
      [% BLOCK bar %]
      ...
      [% END %]
   [% END %]

The problem is that if the parser bombs out while parsing a BLOCK, the
DEFBLOCKS doesn't get cleared.  When the parser tries again next time,
it thinks it's still inside the 'foo' block.  So it ends up thinking
'foo' is 'foo/foo' and 'foo/bar' is 'foo/foo/bar'.

That's why it couldn't find the block you asked for - the parser had
screwed the name up.

Clear the DEFBLOCKS explicitly every time the parser begins a parse()
and the problem goes away!

Changes are in CVS.

Cheers
A


_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to