You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Brydon Cheyney <br...@2fluid.co.uk> on 2002/07/24 18:36:38 UTC

escaping double quotes in strings

hi,

according to the user guide, if the right hand side of a #set directive, is
a string literal, strings quoted by "..." are interpolated, while strings
quoted by '...' are not.   this allows you to set variables such as

#set ( $foo = "$bar$baz" )

however, what this does /not/ allow you to do it seems is this

#set ($foo = "foo=\"$bar\"" )

which you would imagine would be valid code.  after all, you can quote other
characters within the string literal, so why not double quotes?

or am i missing something?  i'd search the archives on mail-archive, but it
appears the facility is broken.

cheers,
brydon

--
brydon cheyney
senior analyst programmer, 2fluid creative ltd

Re: escaping double quotes in strings

Posted by "Geir Magnusson Jr." <ge...@adeptra.com>.
On 7/24/02 12:36 PM, "Brydon Cheyney" <br...@2fluid.co.uk> wrote:

> 
> hi,
> 
> according to the user guide, if the right hand side of a #set directive, is
> a string literal, strings quoted by "..." are interpolated, while strings
> quoted by '...' are not.   this allows you to set variables such as
> 
> #set ( $foo = "$bar$baz" )
> 
> however, what this does /not/ allow you to do it seems is this
> 
> #set ($foo = "foo=\"$bar\"" )
> 
> which you would imagine would be valid code.  after all, you can quote other
> characters within the string literal, so why not double quotes?

Do you mean escape?  - you can't escape characters in Velocity.

> 
> or am i missing something?  i'd search the archives on mail-archive, but it
> appears the facility is broken.

No, not broken.

In 1.4, there is an existing proposal for doing

  #set($foo = " This is ""quoted""!")
  #set($foo = ' This is ''quoted''!')

because it's backwards compatible.

-- 
Geir Magnusson Jr. 
Research & Development, Adeptra Inc.
geirm@adeptra.com
+1-203-247-1713



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>