You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by Leandro Rodrigo Saad Cruz <le...@ibnetwork.com.br> on 2003/08/22 20:14:59 UTC

Escaping macros inside double quotes

Hi all. Is this supposed to work ?

#set($macroSignature = "\#myMacro()")

I can't make this work. I'm using velocity-1.3

-- 
Leandro Rodrigo Saad Cruz
IT - Inter Business Tecnologia e Servicos (IB)
http://www.ibnetwork.com.br
http://db.apache.org/ojb
http://xingu.sourceforge.net


Re: Escaping macros inside double quotes

Posted by Nathan Bubna <na...@esha.com>.
Leandro Rodrigo Saad Cruz said:
> Hi all. Is this supposed to work ?
> 
> #set($macroSignature = "\#myMacro()")
> 
> I can't make this work. I'm using velocity-1.3

please address usage questions to the velocity-user list.  thanks!

Nathan Bubna
nathan@esha.com

Re: Escaping macros inside double quotes

Posted by Leandro Rodrigo Saad Cruz <le...@ibnetwork.com.br>.
On Sat, 2003-08-23 at 11:26, Geir Magnusson Jr. wrote:
> 
> On Friday, August 22, 2003, at 02:14 PM, Leandro Rodrigo Saad Cruz 
> wrote:
> 
> > Hi all. Is this supposed to work ?
> >
> > #set($macroSignature = "\#myMacro()")
> >
> > I can't make this work. I'm using velocity-1.3
> 
> You should be able to just do
> 
>    #set($macroSignature = '#myMacro()')

Thanx. I'm already using that.
My problem is that I must include single quotes inside single quotes and
I can't scape them. The following example doesn't work :
'my \'example\'' 
Doesn't output my 'example'

I'd like to use double quotes because there are some variables and
macros the should be evaluated. Example :

<velocity>
#set ($macroName = '#myMacro()')
#set ($macroSinature = "\#render($macroName)"

$macroName
</velocity>

Should output

#render(#myMacro())




 
 
-- 
Leandro Rodrigo Saad Cruz
IT - Inter Business Tecnologia e Servicos (IB)
http://www.ibnetwork.com.br
http://db.apache.org/ojb
http://xingu.sourceforge.net


Re: Escaping macros inside double quotes

Posted by "Geir Magnusson Jr." <ge...@adeptra.com>.
On Friday, August 22, 2003, at 02:14 PM, Leandro Rodrigo Saad Cruz 
wrote:

> Hi all. Is this supposed to work ?
>
> #set($macroSignature = "\#myMacro()")
>
> I can't make this work. I'm using velocity-1.3

You should be able to just do

   #set($macroSignature = '#myMacro()')

The reason is that single quotes don't attempt to 'render' their 
content.  For example :


#set($foo = "I'm foo!")
#set($bar = '$foo')
#set($woogie = "$foo")

$foo
$bar
$woogie


will output :

I'm foo!
$foo
I'm foo!

-- 
Geir Magnusson Jr                                   203-956-2604(w)
Adeptra, Inc.                                       203-434-2093(m)
geirm@adeptra.com                                   203-247-1713(m)