velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Dekany" <>
Subject Re: Whitespace, redux
Date Wed, 10 Apr 2002 21:39:29 GMT
----- Original Message -----
From: "Steven Hugg" <>
To: <>
Sent: Wednesday, April 10, 2002 1:58 AM

> * Given a text fragment between two directives, if it is entirely made up
> whitespace, do not output that fragment.
> This would let you do things like this:
>     #if($fooCondition)
>         #**# whitespace tamed #**#
>     #end

I think a more general purpose and more obvious rule would be:

If a line is looks like this:
  TemplateLine ::=
      WSSchomo? Directive (WSSchomo? Directive)* WSSchomo? LineEnd
  WSSchomo ::= (#x20 | #x09)+
  LineEnd ::= ((#x0D #x0A) | #x0D | #x0A) | EndOfStream
then the first "WSSchomo?" and the closing "WSSchomo? LineEnd" should be
gobbled. (Note that it supports multiline directives, that is why
"TemplateLine" is not simply "Line".)

Directive #echo('whatever') can be used to output any text, and combined
with the whitespace gobbling it gives total controll over whitespaces:
    #echo('whitespace tamed')
    #echo(' <- one-space')
and it is also a good way to do a safe context independent escaping of
reserved characters:
  #echo('##not a commend')

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message