[Templates] Re: PROPOSAL: Add COMMENT BLOCK directive.

Josh Rosenbaum josh@infogears.com
Thu, 14 Jun 2007 10:53:02 -0600


Paul Seamons wrote:
[SNIP]
> Thinking from a parser standpoint it would be easier and faster if we did 
> something like
> 
> [%#*
> 
>   This is a block comment - notice the matching opening and closing comment 
> tags.
>   [% foo
> 
> *#%]
> 
> This is a little more similar to how the Velocity syntax does their block 
> comment.  They actually use # for their tag delimeter so their block comment 
> is
> 
> #* comment goes here *#
> 
> Using the [%#* Way is easy to check for and would allow a fast parse to the 
> closing tag.  It would also allow you to have broken TT inside the comment.  
> This is one failing of the COMMENT directive is that the TT inside still has 
> to be valid.  A true block comment will allow for anything.

I would love to see better handling of comments containing TT tags. I've been bitten by the TT tags inside comment deal before and now I often just use the following for all my more complex comments:
[% BLOCK comment1 %]commented text[% END %]

Having a [%#* *#%] would be very nice. I would prefer that over the [% COMMENT %]...[% END %] syntax.

Possible bonus points if it can handle comments inside comments. For example by detecting the character after the '#'. ie:
[%#1
  blah...
  [%#0
  foo ...
  [%#* Some other crazy code *#%]
  bar...
  0#%]
1#%]

-- Josh