velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christoph.R...@dlr.de
Subject Re: Rendering with escapes.
Date Mon, 24 Mar 2003 13:06:44 GMT
Hi,

there seems to be some problems with reference and directive escaping in
velocity. A failsafe way of escaping can be achieved as follows:

#set( $Q = '"' )
#set( $D = '$' )
#set( $P = '#' )
...
You can use the above definitons to write directives to the output:
   ${P}if( ${D}email )Hello World!${P}end

Not very nice, but 100% predictable - and better than \\\$email :-D


The reason velocity acts like this with the escapes is described
in the documentation. Velocity behaves differently whether the
reference is in the context or not.


Hope this helps,
Christoph


matti.j.aaltonen@nokia.com wrote:
> Hello.
> 
> I just started using Velocity. The text below is taken from the Velocity User Guide.
I didn't understand why \\\$email would render as \\\$email. I tried it and it renders as
\\$email. Am I  missing something?
> 
> Cheers,
> Matti Aaltonen
> 
> 
> Note that the \ character bind to the $ from the left. The bind-from-left rule causes
\\\$email to render as \\$email. Compare these examples to those in which > > $email
is not defined. 
>    
> $email
> \$email
> \\$email
> \\\$email
> 
> renders as 
>    
>  $email
> \$email
> \\$email
> \\\$email
> 
> 
>   
>    
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> 
> 

-- 
:) Christoph Reck


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


Mime
View raw message