You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Je...@bmw.de on 2006/09/26 10:54:59 UTC

Mistake

Hello,

 

i think you have a mistake in "Advanced Issues: Escaping and !"

 

 

Original Text:

 

Contrast this with regular escaping, where \ precedes $: 

\$foo

\$!foo

\$!{foo}

\\$!{foo}

This renders as: 

\$foo

\$!foo

\$!{foo}

\bar

 

 

I think it should be like this: (Change is marked red)

 

Contrast this with regular escaping, where \ precedes $: 

\$foo

\$!foo

\$!{foo}

\\$!{foo}

This renders as: 

$foo

\$!foo

\$!{foo}

\bar

 

 

Best regards

 

Jens Futterer

 

------------------------------------------

BMW Group

Jens Futterer

Diplomand EG-660

Versuch und Modelltechnik/Prozesse und Simulation

Telefon: +49 (0) 89 / 382-78182

mailto: Jens.Futterer@bmw.de

URL: http://www.bmwgroup.com <http://www.bmwgroup.com> 

-------------------------------------------

 


Re: Mistake

Posted by ap...@recks.org.
Hi Jens,

velocity acts differently if $foo is in the context or not.

The documentation example you quoted seems to be for the
case where the key "foo" was in the context, in which case
the presented reply in this thread from "trad-ex" user is
more correct.

When $foo is not in the context I would expect the last line
\\$!{foo} to render as (collating the backslash): \$!{foo}
but the behavior of "escaping an escape" is broken and
many times produces unexpected/unexplainable output.

I recommend you use the poor-mans-escaping(TM) velocity gives
you for free:
#set( $D = '$' )
#set( $B = '\' )
#set( $H = '#' )
#set( $N = '!' )
Now you can write things like $B$D$N{foo} to precisely render
what you want. Note that you would only need to escape the $
in such a case: \$D!{foo} which is almost as readable as \\$!{foo}

Cheers,
Christoph

P.S. Jens, be aware, if you write to mailing lists with your
business email address, you will later receive a *lot* of
spam - because lists are electronically harvested by bad guys
for good addresses... You will then see how good/bad BMW
IT-Infrastructure is filtering out the spam...

Jens.Futterer@bmw.de wrote:
> Hello,
> 
>  
> 
> i think you have a mistake in "Advanced Issues: Escaping and !"
> 
>  
> Original Text:
> 
> Contrast this with regular escaping, where \ precedes $: 
> 
> \$foo
> \$!foo
> \$!{foo}
> \\$!{foo}
> 
> This renders as: 
> 
> \$foo
> \$!foo
> \$!{foo}
> \bar
>  
> 
> I think it should be like this: (Change is marked red)
> 
> 
> Contrast this with regular escaping, where \ precedes $: 
> 
> \$foo
> \$!foo
> \$!{foo}
> \\$!{foo}
> 
> This renders as: 
> 
> $foo
> \$!foo
> \$!{foo}
> \bar
> 
> 
> Best regards
>  
> 
> Jens Futterer
> 
>  
> 
> ------------------------------------------
> BMW Group
> Jens Futterer
> Diplomand EG-660
> Versuch und Modelltechnik/Prozesse und Simulation
> 
> Telefon: +49 (0) 89 / 382-78182
> 
> mailto: Jens.Futterer@bmw.de
> 
> URL: http://www.bmwgroup.com <http://www.bmwgroup.com> 
> 
> -------------------------------------------


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


Re: Mistake

Posted by trad-ex <tr...@inter7.jp>.
Hi Jens,

I think (and tested them below):

>Contrast this with regular escaping, where \ precedes $: 
>
>\$foo

-> $foo

>\$!foo

-> $!foo

>\$!{foo}

-> $!{foo}

>\\$!{foo}

-> \bar

("->" just means "arrow" :-) ) 

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