You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Sebastien Chassande-Barrioz <se...@inrialpes.fr> on 2002/03/11 08:19:51 UTC
" character
hi,
I have a problem to set a variable with the " character:
#set($toto="hello")
#set($foo="\"${toto}")
$foo
renders:
\"hello
but I would like just:
"hello
The following other case occurs an error:
#set($foo=""${toto}")
I does not find in the documentation any information about escaping the
" character in a string. How is it possible ?
regards,
Seb
--
Chassande-Barrioz Sebastien
INRIALPES - SIRAC/SARDES Team - ObjectWeb initiative
Mail job : sebastien.chassande@inrialpes.fr
Phone : 04.76.61.55.16
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: " character
Posted by Christoph Reck <Ch...@dlr.de>.
The current way of getting a quote into a string is using
a formal declaration:
#set( $Q = '"' )
#set( $foo="$Q$toto" )
Note that anything within single quotes in a VTL parameter (within
a set or in a method call) will not be touched by Velocity.
so you can also write #set($foo='"hello').
Note that I use a similar trick to get newlines into strings:
#set( $NL = $forms.uudecode('%0A') )## $forms is a user written context tool.
Hope this helps,
:) Christoph
Sebastien Chassande-Barrioz wrote:
>
> hi,
>
> I have a problem to set a variable with the " character:
> #set($toto="hello")
> #set($foo="\"${toto}")
#set( $foo="$Q$toto" )
> $foo
>
> renders:
> \"hello
now renders:
"hello
>
> but I would like just:
> "hello
>
> The following other case occurs an error:
> #set($foo=""${toto}")
>
> I does not find in the documentation any information about escaping the
> " character in a string. How is it possible ?
>
> regards,
> Seb
> --
> Chassande-Barrioz Sebastien
> INRIALPES - SIRAC/SARDES Team - ObjectWeb initiative
> Mail job : sebastien.chassande@inrialpes.fr
> Phone : 04.76.61.55.16
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
--
:) Christoph Reck
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>