velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Dekany" <ddek...@freemail.hu>
Subject Re: Whitespace, redux
Date Wed, 10 Apr 2002 21:39:29 GMT
----- Original Message -----
From: "Steven Hugg" <hugg@fasterlight.com>
To: <velocity-user@jakarta.apache.org>
Sent: Wednesday, April 10, 2002 1:58 AM


[snip]
> * Given a text fragment between two directives, if it is entirely made up
of
> 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:

a)
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".)

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


--
To unsubscribe, e-mail:   <mailto:velocity-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:velocity-user-help@jakarta.apache.org>


Mime
View raw message