You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Marco Papini <mp...@cinetica.it> on 2002/06/14 20:14:49 UTC

Escaping double quote in #set

Hi all,

I'm playing around with Velocity and I got a strange result (IMHO) in a 
string concatenation operation.

That's the set command:

#set( $invalidPKString = "$invalidPKString + ${column.variableName} + \" 
\"" )

I expected ${invalidPKString} would render, if ${column.variableName} = 
"id" and ${invalidPKString} = "" :

+ id + " "

but I got :

+ id + \" \"

Is there anything wrong ? Isn't the backslash the escape character ?

Thanks in advance

Marco



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


Re: Escaping double quote in #set

Posted by "Geir Magnusson Jr." <ge...@adeptra.com>.
On 6/17/02 3:53 AM, "Marco Papini" <mp...@cinetica.it> wrote:

> Many thanks, it's ok.
> 
> Why do you prefer the "" to \" ? Isn't the \ already used as an escape
> character ? IMHO it's simplier to have just one escape char.

Currently, there is no escape character for string literals.  Yes, we do use
the \ for escaping references and directives...

We have had long discussions about this - there are many who believe that
the whole \ escaping thing is confusing for designers.... There were quite a
few threads on this.

We all seem pretty happy with "", but it's clearly not to late to renew this
discussion :0

-- 
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>


Re: Escaping double quote in #set

Posted by Marco Papini <mp...@cinetica.it>.
Many thanks, it's ok.

Why do you prefer the "" to \" ? Isn't the \ already used as an escape 
character ? IMHO it's simplier to have just one escape char.

Marco

Geir Magnusson Jr. wrote:
> On 6/14/02 2:14 PM, "Marco Papini" <mp...@cinetica.it> wrote:
> 
[SNIP]
>>
>>Is there anything wrong ? Isn't the backslash the escape character ?
>>
> 
> No.  There are no escape sequences in string literals
> 
> Coming (when I finish the parser surgery) will be "" to denote what you
> want, so you would
[SNIP]


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


Re: Escaping double quote in #set

Posted by "Geir Magnusson Jr." <ge...@adeptra.com>.
On 6/14/02 2:14 PM, "Marco Papini" <mp...@cinetica.it> wrote:

> Hi all,
> 
> I'm playing around with Velocity and I got a strange result (IMHO) in a
> string concatenation operation.
> 
> That's the set command:
> 
> #set( $invalidPKString = "$invalidPKString + ${column.variableName} + \"
> \"" )
> 
> I expected ${invalidPKString} would render, if ${column.variableName} =
> "id" and ${invalidPKString} = "" :
> 
> + id + " "
> 
> but I got :
> 
> + id + \" \"
> 
> Is there anything wrong ? Isn't the backslash the escape character ?
> 

No.  There are no escape sequences in string literals

Coming (when I finish the parser surgery) will be "" to denote what you
want, so you would

"$a + ${b.c} + "" """

To do that.

The solution is just to do :

#set($dq = '"')

And then

#set($ipkstr = "$ipkstr + ${col.var} + $dq$dq")



-- 
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>