Hi Shailendra,

escaping within quotes is not supported by Velocity. Escaping the
\$reference and \#directives is implmented, but sometimes does not
behave as desired. Therefore use the failsafer and ever-working
poor-man's-escaping(tm) of velocity:

#set( $D = '$' )
#set( $H = '#' )
#set( $Q = '"' )
#set( $S = "'" )
And use it:

#set( $tab = ".... href=${Q}javascript:tab('a1','a2','a3')${Q} ...." )
${H}if( ${D}foo )OK${H}end

Please note that velocity allow string declarations with single
and double quotes. Where single quoted strings are treated literally,
wherease double quieted strings are parsed and contained directives
and references are interpolated:
#set( $foo = '$bar' )
#set( $baz = "$foo" )## will contain the string $bar


I remember in the threads that an upcoming release velocity will
support notation of escaping by doubling the quotes within the
string, so:
  #set( $tab = ".... href=""javascript:tab('a1','a2','a3')"" ...." )
might work with a nightly build...

:) Christoph Reck


Shailendra Kumar Vikas wrote:
Hi All,
I am trying to generate some HTML code from the velocity code . I need
to build the HTML syntax and keep it in a string . I want to have a
syntax like the following .... href="javascript:tab('a1','a2','a3')" ....
But i am not able to do so because if i put \" in the string than the
string take \" and not " . So '\' does not act as a escape char . Please
suggest me how to build the string which may have " in it .

Thanks in advance,
Shailendra



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to