You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Matt Higgins <mh...@bluesocket.com> on 2004/09/09 20:04:57 UTC

Escape a double quote "

I have a macro that produces html and I need to escape a double quote
i.e. "

An example may be helpful 

#macro(showimage $imagePath)
	#set ($output = "<img class="foo" src="$imagePath">")
        <table>
	<tr><td>$output</td></tr>
	</table>
#end

I would like it to produce 
<table>
<tr><td><img class="foo" src="/path/to/file.jpg"></td><tr>
</table>

The above code obviously pukes, however I tried to escape the contained
quotes with \" but that did not output any quotes. I searched around the
site but could not find anything ? 

Any help with this would be appreciated. 

-Matt

		

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: Escape a double quote "

Posted by Christoph Reck <ap...@recks.org>.
Use the poor-mans's escaping...

Matt Higgins wrote:
> I have a macro that produces html and I need to escape a double quote
> i.e. "
> 
> An example may be helpful 
> 
#set( $Q = '"' )
> #macro(showimage $imagePath)
> 	#set ($output = "<img class="foo" src="$imagePath">")

	#set ($output = "<img class=${Q}foo${Q} src=${Q}$imagePath${Q}>")

or the HTML alternative of single quotes:

  	#set ($output = "<img class='foo' src='$imagePath'>")

>         <table>
> 	<tr><td>$output</td></tr>
> 	</table>
> #end
> 
> I would like it to produce 
> <table>
> <tr><td><img class="foo" src="/path/to/file.jpg"></td><tr>
> </table>
> 
> The above code obviously pukes, however I tried to escape the contained
> quotes with \" but that did not output any quotes. I searched around the
> site but could not find anything ? 
> 
> Any help with this would be appreciated. 
> 
> -Matt
> 

Cheers,
Christoph

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org