[Templates] Chomp Directive?

Josh Rosenbaum josh@infogears.com
Fri, 20 Apr 2007 10:57:03 -0600


Andy Wardley wrote:
[SNIP]
> 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 %]

Sounds great. Thanks for the explanation. Since it sounds like you're going to put a good push on TT3, it might be good to note that Sean McAfee mentioned adding some sort of config directive. ie: [% CONFIG PRE_CHOMP off %] or [% CONFIG INTERPOLATE off %]. It seems like a good idea as it might make it easier to handle various other config changes.

-- Josh