On Tue, Apr 16, 2002 at 02:10:15PM -0700, Bill Moseley wrote:
> >  [% stag = "[\%"
> >     etag = "%\]"
> >  %]
> 
> What's the logic for the backslash?  I would have expected 

The parser works in 2 passes.  First, the split_text() method splits
the template into directives and text.  The backslash confounds it and
stops it from thinking it's a real start/end of directive.

Then, the tokenise_directive() method kicks in, parses the double quoted
string and unescapes the escaped characters so that you end up with what 
you want.

>   [% stag = "\[%"
>      etag = "\%]"
>   %]

This would get parsed as:

   [% stag = "\[%" etag = "\%]" %]
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^
   [% DIRECTIVE             %]

> Or more perlish
> 
>   [% stag = '[%'
>      etag = '%]'
>   %]

Similarly,

   [% stag = '[%' etag = '%]' %]
   ^^^^^^^^^^^^^^^^^^^^^^^^^
   [% DIRECTIVE           %]


> >  [% TAGS star %]
> >  [% INCLUDE foo %]   # not a directive, just plain text, passed through
> >  [* INCLUDE foo *]   # is a directive
> 
> More work for the existing template.  It would be cool if TAGS was somehow
> block scoped, although I can't see how you would END the block -- with new
> or old tag?

In v3 the parser configuration (start/end tag, interpolate flags, etc) can
indeed be block scoped.  Not sure of the syntax, but probably something like
this:

  [% PARSE
       start_tag   = '[*'
       end_tag     = '*]'
       interpolate = 1
  %]

     ...

  [% END %]


A



Reply via email to