You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Gu Dake <fo...@hotmail.com> on 2003/01/29 09:57:51 UTC

velocity string literal

Hi,I wrote the following template code: 

#set( $value = "hello\"") 
$value 


The result is: 
hello\" 

not expected: 
hello" 

Can someone tell me how to write a string literal hello" 

_________________________________________________________________
与联机的朋友进行交流,请使用 MSN Messenger:  http://messenger.msn.com/cn  


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


Re: velocity string literal

Posted by Ch...@dlr.de.
Hi Gu,

velocity being a template language and not a programming language
does not support escaping as you tried. The fail-safe way of
doing this is:

#set( $qq = '"' )
#set( $value = "hello${qq}" ) $value


This has been discussed in other threads. In a future release
velocity might support quote escape by doubling the quote
itself, also in your example: #set( $value = "hello""")
which would remain backward compatible.

The velocity documentation and FAQ maybe needs to be *very*
clear on this quote issue to ease the learning cure for new
users.

-- 
:) Christoph Reck


Gu Dake wrote:
> Hi,I wrote the following template code:
> #set( $value = "hello\"") $value
> 
> The result is: hello\"
> not expected: hello"
> Can someone tell me how to write a string literal hello"
> _________________________________________________________________
> 与联机的朋友进行交流,请使用 MSN Messenger:  http://messenger.msn.com/cn 
> 
> ---------------------------------------------------------------------
> 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