Sergey Martynoff wrote:
> Me too :) But I was telling not about block capturing, but about
> having literals '[%' or '%]' in string without breaking the
> parser.

Yes, that's a separate matter.  It's broken by the fact that the 
TT2 parser pre-scans a tag, capturing everything between the [%
and the first %] it encounters.

  [% token = '%]' %]   # TT2 error!
  ^^----------^^

In TT3 we scan the opening token, then call on the tag handler to 
scan the contents (which it does "intelligently" using the recursive
descent part of the parser described in my previous post) and then 
scan the closing tag afterwards.  

  [% token = '%]' %]   # TT3 success!
  ^^--------------^^

Furthermore, in TT3 you can nest tags if you want to.

e.g.

  [% a = [% INCLUDE header | html %] %]

  [% INCLUDE footer
       copyright = [% INCLUDE site/copyright year=2005 %]
  %]

Although this has the potential to get ugly real quickly if used to 
excess, it is a handy bit of syntactic sugar that can make some hard
things a little easier.  I'm not yet decided on how far to go with this,
but I've got it working as a proof-of-concept.

A


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

Reply via email to