Discussion:
escaping double quotes in strings
Brydon Cheyney
2002-07-24 16:36:38 UTC
Permalink
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
Brydon Cheyney
2002-07-24 16:38:50 UTC
Permalink
....

ok, so it appears the htdig search is back. =) the solution set by geir
magnusson in
http://www.mail-archive.com/velocity-***@jakarta.apache.org/msg05289.html
is doable, but hardly optimal. has there been any more discussion into
integrating this functionality into the parsing of string literals in #set
directives? geir mentions having code kicking around for this....

- brydon

--
brydon cheyney
senior analyst programmer, 2fluid creative ltd
Geir Magnusson Jr.
2002-07-25 02:32:31 UTC
Permalink
Post by Brydon Cheyney
....
ok, so it appears the htdig search is back. =) the solution set by geir
magnusson in
is doable, but hardly optimal.
Clearly not optimal :)
Post by Brydon Cheyney
has there been any more discussion into
integrating this functionality into the parsing of string literals in #set
directives? geir mentions having code kicking around for this....
--
Geir Magnusson Jr.
Research & Development, Adeptra Inc.
***@adeptra.com
+1-203-247-1713
Geir Magnusson Jr.
2002-07-25 02:31:57 UTC
Permalink
Post by Brydon Cheyney
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.
Post by Brydon Cheyney
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.
***@adeptra.com
+1-203-247-1713
Brydon Cheyney
2002-07-25 08:25:31 UTC
Permalink
Post by Geir Magnusson Jr.
Post by Brydon Cheyney
or am i missing something? i'd search the archives on
mail-archive, but it appears the facility is broken.
No, not broken.
sorry, i didn't mean the velocity directive - the search facility on
/mail-archive/ was broken... =) the ht database needed merged, and was
down for most of yesterday.
Post by Geir Magnusson Jr.
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.
this sounds good....

thanks,
brydon

--
brydon cheyney
senior analyst programmer, 2fluid creative ltd
Geir Magnusson Jr.
2002-07-25 10:02:05 UTC
Permalink
Post by Brydon Cheyney
Post by Geir Magnusson Jr.
Post by Brydon Cheyney
or am i missing something? i'd search the archives on
mail-archive, but it appears the facility is broken.
No, not broken.
sorry, i didn't mean the velocity directive - the search facility on
/mail-archive/ was broken... =) the ht database needed merged, and was
down for most of yesterday.
Now that I re-read the sentence, it's clear what you meant :) Must have
been pretty tired... :)
Post by Brydon Cheyney
Post by Geir Magnusson Jr.
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.
this sounds good....
thanks,
brydon
--
brydon cheyney
senior analyst programmer, 2fluid creative ltd
--
Geir Magnusson Jr.
Research & Development, Adeptra Inc.
***@adeptra.com
+1-203-247-1713
Loading...