Josh Rosenbaum wrote:
It would be nice to have a tag to control the chomping method in TT similar to the TAGS directive. (ie: [% TAGS <! !> %])

Yes, I totally agree.

The main reason we don't have more directives like that is that TT2's parser
is somewhat inflexible and requires a bunch of dirty hacks to make things
like this work.  It's a nasty case of "Write once, edit at your peril" :-)

One of the main goals for TT3's parser is to make it easier to add new
directives.  Not just for the sake of us core developers, but also to
allow users to add their own custom directives, disable inbuilt ones,
and generally tweak the language to their liking or particular application.

I'm thinking:
[% PRE_CHOMP CHOMP_NONE %]
[% POST_CHOMP CHOMP_ALL %]

or maybe:
[% CHOMP CHOMP_NONE CHOMP_ALL %]
or:
[% CHOMP NONE ALL %]

Another benefit of TT3's parser is that it uses recursive descent to parse
the directives rather than the pre-tokenised table-driven approach of TT2.
What that means in practice is that we can be a lot more flexible about the
syntax we use for different directives.  For example, we can use recognise
'on', 'off', 'all', 'none', and so on, as values for options without having
to define them up-front as global keyword tokens like we do in TT2 (which
effectively prevents you from using them as variable names).

So that would allow us to write things like this:

  [% PRE_CHOMP off %]
  [% POST_CHOMP on %]
  [% PRE_CHOMP all %]
  [% POST_CHOMP collapse %]
  [% CHOMP before %]
  [% CHOMP after %]
  [% CHOMP both %]

As well as the CHOMP options and TAGS which you already mentioned, the other
"compile time" switch will be INTERPOLATE.  As per TT2's config option, this
tells the parser to interpolate simple $var variables in the text (or not).

  [% INTERPOLATE off %]
  [% INTERPOLATE on %]

Cheers
A


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

Reply via email to