You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Robert Edgar <ro...@eeplace.com> on 2001/11/19 09:20:02 UTC

Problem with escaped $ not appearing in output

Help!
I have a macro defined as below

#macro(PanelC $lcid)
<esi:include
src="/servlet/forumManager?action=threadlist&forumid=\$(QUERY_STRING{forumid
})&page=\$(QUERY_STRING{page})&daysprune=\$(QUERY_STRING{daysprune})&lcid=${
lcid}&dummy=1"/>
#end

The problem I get is that the two escaped $ dont appear at all in the
output, everything else is OK.

Anyone know what I am doing wrong?

Rob


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


Re: Problem with escaped $ not appearing in output

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
There's a fix in 1.3 related to that - that's the current CVS.

Grab the nightly snapshot, build , and try that...


On 11/19/01 7:35 AM, "Robert Edgar" <ro...@eeplace.com> wrote:

> Jakarta Velocity v1.2-rc3
> 
> OK here is the full code
> #set($lcid = "1033")
> 
> #macro(PanelC $lcid)
> <esi:include
> src="/servlet/forumManager?action=threadlist&forumid=$(QUERY_STRING{forumid}
> )&page=$(QUERY_STRING{page})&daysprune=$(QUERY_STRING{daysprune})&lcid=${lci
> d}"/>
> #end
> 
> #set($panelC = "#PanelC($lcid)")
> 
> #parse("/template/common/stdPage3.vtl")
> 
> where the tamplate stdPage3.vtl contains the variable $panelC
> 
> 
> currently the above outputs
> <esi:include
> src="/servlet/forumManager?action=threadlist&forumid=(QUERY_STRING{forumid})
> &page=(QUERY_STRING{page})&daysprune=(QUERY_STRING{daysprune})&lcid=1033"/>
> 
> so somewhere the $ get stripped out...
> 
> I assume that velocity will try to interpret the $ as a variable reference
> and so strip it out and replace it with nothing.
> 
> Previously I had assigned the ESI string to a variable wrapping it with ' '
> which instructs velocity to NOT parse it, and this works OK
> ... BUT...
> The problem was I wanted to add a real velocity var $lcid into the string
> and I couldnt find a way to assign to a variable some string that part of
> which needs to be parsed and part of which should not be, so I figured using
> a macro would solve the problem.
> 
> Rob
> 
> 
> 
> -----Original Message-----
> From: Geir Magnusson Jr. [mailto:geirm@optonline.net]
> Sent: Monday, November 19, 2001 8:08 PM
> To: velocity-user@jakarta.apache.org
> Subject: Re: Problem with escaped $ not appearing in output
> 
> 
> On 11/19/01 6:58 AM, "Robert Edgar" <ro...@eeplace.com> wrote:
> 
>> Yep it was 3, just cant count :-)
>> 
>> 
>> actually what I want in the output is
>> $(QUERY_STRING{daysprune})
>> 
>> not
>> 
>> \$(QUERY_STRING{daysprune})
>> 
>> I put the \ in front so that when velocity parses it it will leave the $
>> untouched and not try to interpret it as a variable reference.
>> 
>> I dont have any choice in this as ESI syntax uses $() to denote
> variables...
> 
> But I *was* getting the $, just not the "\$".  I didn't understand why you
> would want the \$, but figured you had a reason. :)
> 
> What version are you using?
> 
>> 
>> Thanks
>> Rob
>> 
>> -----Original Message-----
>> From: Geir Magnusson Jr. [mailto:geirm@optonline.net]
>> Sent: Monday, November 19, 2001 7:36 PM
>> To: velocity-user@jakarta.apache.org
>> Subject: Re: Problem with escaped $ not appearing in output
>> 
>> 
>> On 11/19/01 3:20 AM, "Robert Edgar" <ro...@eeplace.com> wrote:
>> 
>>> Help!
>>> I have a macro defined as below
>>> 
>>> #macro(PanelC $lcid)
>>> <esi:include
>>> 
>> 
> src="/servlet/forumManager?action=threadlist&forumid=\$(QUERY_STRING{forumid
>>> })&page=\$(QUERY_STRING{page})&daysprune=\$(QUERY_STRING{daysprune})&lcid
> =
>> ${
>>> lcid}&dummy=1"/>
>>> #end
>>> 
>>> The problem I get is that the two escaped $ dont appear at all in the
>>> output, everything else is OK.
>>> 
>>> Anyone know what I am doing wrong?
>>> 
>> 
>> You are on a roll... :)
>> 
>> That's 3 escaped $, right?
>> 
>> I assume that you wanted the '\$' character sequence to appear literally,
>> such as
>> 
>> .... \$(QUERY_STRING{forumid})&page....
>> 
>> in the output?
>> 
>> If so, you are 2-0 this morning in bug finding, as this is another bug,
> and
>> an odd one at that...
>> 
>> The workaround, for now, is something like
>> 
>> 
>> #macro(PanelC $lcid)
>> #set($sl = '\')
>> <esi:include
>> 
> src="/servlet/forumManager?action=threadlist&forumid=${sl}$(QUERY_STRING{fo
>> 
> rumid})&page=${sl}$(QUERY_STRING{page})&daysprune=\$(QUERY_STRING{daysprune}
>> )&lcid=${lcid}&dummy=1"/>
>> #end
>> 
>> Which isn't great, but gets you going.
>> 
>> 
>> 
>> --
>> Geir Magnusson Jr.                                     geirm@optonline.net
>> System and Software Consulting
>> "They that can give up essential liberty to obtain a little temporary
> safety
>> deserve neither liberty nor safety." - Benjamin Franklin
>> 
>> 
>> 
>> --
>> To unsubscribe, e-mail:
>> <ma...@jakarta.apache.org>
>> For additional commands, e-mail:
>> <ma...@jakarta.apache.org>
>> 
>> 
>> 
>> 
>> --
>> To unsubscribe, e-mail:
>> <ma...@jakarta.apache.org>
>> For additional commands, e-mail:
>> <ma...@jakarta.apache.org>
>> 
> 
> --
> Geir Magnusson Jr.                                     geirm@optonline.net
> System and Software Consulting
> "He who throws mud only loses ground." - Fat Albert
> 
> 
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 

-- 
Geir Magnusson Jr.     geirm@optonline.net
System and Software Consulting
"Whoever would overthrow the liberty of a nation must begin by subduing the
freeness of speech." - Benjamin Franklin



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


RE: Problem with escaped $ not appearing in output

Posted by Robert Edgar <ro...@eeplace.com>.
Jakarta Velocity v1.2-rc3

OK here is the full code
#set($lcid = "1033")

#macro(PanelC $lcid)
<esi:include
src="/servlet/forumManager?action=threadlist&forumid=$(QUERY_STRING{forumid}
)&page=$(QUERY_STRING{page})&daysprune=$(QUERY_STRING{daysprune})&lcid=${lci
d}"/>
#end

#set($panelC = "#PanelC($lcid)")

#parse("/template/common/stdPage3.vtl")

where the tamplate stdPage3.vtl contains the variable $panelC


currently the above outputs
<esi:include
src="/servlet/forumManager?action=threadlist&forumid=(QUERY_STRING{forumid})
&page=(QUERY_STRING{page})&daysprune=(QUERY_STRING{daysprune})&lcid=1033"/>

so somewhere the $ get stripped out...

I assume that velocity will try to interpret the $ as a variable reference
and so strip it out and replace it with nothing.

Previously I had assigned the ESI string to a variable wrapping it with ' '
which instructs velocity to NOT parse it, and this works OK
... BUT...
The problem was I wanted to add a real velocity var $lcid into the string
and I couldnt find a way to assign to a variable some string that part of
which needs to be parsed and part of which should not be, so I figured using
a macro would solve the problem.

Rob



-----Original Message-----
From: Geir Magnusson Jr. [mailto:geirm@optonline.net]
Sent: Monday, November 19, 2001 8:08 PM
To: velocity-user@jakarta.apache.org
Subject: Re: Problem with escaped $ not appearing in output


On 11/19/01 6:58 AM, "Robert Edgar" <ro...@eeplace.com> wrote:

> Yep it was 3, just cant count :-)
>
>
> actually what I want in the output is
> $(QUERY_STRING{daysprune})
>
> not
>
> \$(QUERY_STRING{daysprune})
>
> I put the \ in front so that when velocity parses it it will leave the $
> untouched and not try to interpret it as a variable reference.
>
> I dont have any choice in this as ESI syntax uses $() to denote
variables...

But I *was* getting the $, just not the "\$".  I didn't understand why you
would want the \$, but figured you had a reason. :)

What version are you using?

>
> Thanks
> Rob
>
> -----Original Message-----
> From: Geir Magnusson Jr. [mailto:geirm@optonline.net]
> Sent: Monday, November 19, 2001 7:36 PM
> To: velocity-user@jakarta.apache.org
> Subject: Re: Problem with escaped $ not appearing in output
>
>
> On 11/19/01 3:20 AM, "Robert Edgar" <ro...@eeplace.com> wrote:
>
>> Help!
>> I have a macro defined as below
>>
>> #macro(PanelC $lcid)
>> <esi:include
>>
>
src="/servlet/forumManager?action=threadlist&forumid=\$(QUERY_STRING{forumid
>> })&page=\$(QUERY_STRING{page})&daysprune=\$(QUERY_STRING{daysprune})&lcid
=
> ${
>> lcid}&dummy=1"/>
>> #end
>>
>> The problem I get is that the two escaped $ dont appear at all in the
>> output, everything else is OK.
>>
>> Anyone know what I am doing wrong?
>>
>
> You are on a roll... :)
>
> That's 3 escaped $, right?
>
> I assume that you wanted the '\$' character sequence to appear literally,
> such as
>
> .... \$(QUERY_STRING{forumid})&page....
>
> in the output?
>
> If so, you are 2-0 this morning in bug finding, as this is another bug,
and
> an odd one at that...
>
> The workaround, for now, is something like
>
>
> #macro(PanelC $lcid)
> #set($sl = '\')
> <esi:include
>
src="/servlet/forumManager?action=threadlist&forumid=${sl}$(QUERY_STRING{fo
>
rumid})&page=${sl}$(QUERY_STRING{page})&daysprune=\$(QUERY_STRING{daysprune}
> )&lcid=${lcid}&dummy=1"/>
> #end
>
> Which isn't great, but gets you going.
>
>
>
> --
> Geir Magnusson Jr.                                     geirm@optonline.net
> System and Software Consulting
> "They that can give up essential liberty to obtain a little temporary
safety
> deserve neither liberty nor safety." - Benjamin Franklin
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>

--
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
"He who throws mud only loses ground." - Fat Albert


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




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


Re: Problem with escaped $ not appearing in output

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 11/19/01 6:58 AM, "Robert Edgar" <ro...@eeplace.com> wrote:

> Yep it was 3, just cant count :-)
> 
> 
> actually what I want in the output is
> $(QUERY_STRING{daysprune})
> 
> not
> 
> \$(QUERY_STRING{daysprune})
> 
> I put the \ in front so that when velocity parses it it will leave the $
> untouched and not try to interpret it as a variable reference.
> 
> I dont have any choice in this as ESI syntax uses $() to denote variables...

But I *was* getting the $, just not the "\$".  I didn't understand why you
would want the \$, but figured you had a reason. :)

What version are you using?

> 
> Thanks
> Rob
> 
> -----Original Message-----
> From: Geir Magnusson Jr. [mailto:geirm@optonline.net]
> Sent: Monday, November 19, 2001 7:36 PM
> To: velocity-user@jakarta.apache.org
> Subject: Re: Problem with escaped $ not appearing in output
> 
> 
> On 11/19/01 3:20 AM, "Robert Edgar" <ro...@eeplace.com> wrote:
> 
>> Help!
>> I have a macro defined as below
>> 
>> #macro(PanelC $lcid)
>> <esi:include
>> 
> src="/servlet/forumManager?action=threadlist&forumid=\$(QUERY_STRING{forumid
>> })&page=\$(QUERY_STRING{page})&daysprune=\$(QUERY_STRING{daysprune})&lcid=
> ${
>> lcid}&dummy=1"/>
>> #end
>> 
>> The problem I get is that the two escaped $ dont appear at all in the
>> output, everything else is OK.
>> 
>> Anyone know what I am doing wrong?
>> 
> 
> You are on a roll... :)
> 
> That's 3 escaped $, right?
> 
> I assume that you wanted the '\$' character sequence to appear literally,
> such as
> 
> .... \$(QUERY_STRING{forumid})&page....
> 
> in the output?
> 
> If so, you are 2-0 this morning in bug finding, as this is another bug, and
> an odd one at that...
> 
> The workaround, for now, is something like
> 
> 
> #macro(PanelC $lcid)
> #set($sl = '\')
> <esi:include
> src="/servlet/forumManager?action=threadlist&forumid=${sl}$(QUERY_STRING{fo
> rumid})&page=${sl}$(QUERY_STRING{page})&daysprune=\$(QUERY_STRING{daysprune}
> )&lcid=${lcid}&dummy=1"/>
> #end
> 
> Which isn't great, but gets you going.
> 
> 
> 
> --
> Geir Magnusson Jr.                                     geirm@optonline.net
> System and Software Consulting
> "They that can give up essential liberty to obtain a little temporary safety
> deserve neither liberty nor safety." - Benjamin Franklin
> 
> 
> 
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 

-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
"He who throws mud only loses ground." - Fat Albert


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


RE: Problem with escaped $ not appearing in output

Posted by Robert Edgar <ro...@eeplace.com>.
Yep it was 3, just cant count :-)


actually what I want in the output is
$(QUERY_STRING{daysprune})

not

\$(QUERY_STRING{daysprune})

I put the \ in front so that when velocity parses it it will leave the $
untouched and not try to interpret it as a variable reference.

I dont have any choice in this as ESI syntax uses $() to denote variables...

Thanks
Rob

-----Original Message-----
From: Geir Magnusson Jr. [mailto:geirm@optonline.net]
Sent: Monday, November 19, 2001 7:36 PM
To: velocity-user@jakarta.apache.org
Subject: Re: Problem with escaped $ not appearing in output


On 11/19/01 3:20 AM, "Robert Edgar" <ro...@eeplace.com> wrote:

> Help!
> I have a macro defined as below
>
> #macro(PanelC $lcid)
> <esi:include
>
src="/servlet/forumManager?action=threadlist&forumid=\$(QUERY_STRING{forumid
> })&page=\$(QUERY_STRING{page})&daysprune=\$(QUERY_STRING{daysprune})&lcid=
${
> lcid}&dummy=1"/>
> #end
>
> The problem I get is that the two escaped $ dont appear at all in the
> output, everything else is OK.
>
> Anyone know what I am doing wrong?
>

You are on a roll... :)

That's 3 escaped $, right?

I assume that you wanted the '\$' character sequence to appear literally,
such as

.... \$(QUERY_STRING{forumid})&page....

in the output?

If so, you are 2-0 this morning in bug finding, as this is another bug, and
an odd one at that...

The workaround, for now, is something like


 #macro(PanelC $lcid)
#set($sl = '\')
 <esi:include
 src="/servlet/forumManager?action=threadlist&forumid=${sl}$(QUERY_STRING{fo
rumid})&page=${sl}$(QUERY_STRING{page})&daysprune=\$(QUERY_STRING{daysprune}
)&lcid=${lcid}&dummy=1"/>
 #end

Which isn't great, but gets you going.



--
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
"They that can give up essential liberty to obtain a little temporary safety
deserve neither liberty nor safety." - Benjamin Franklin



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




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


Re: Problem with escaped $ not appearing in output

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 11/19/01 3:20 AM, "Robert Edgar" <ro...@eeplace.com> wrote:

> Help!
> I have a macro defined as below
> 
> #macro(PanelC $lcid)
> <esi:include
> src="/servlet/forumManager?action=threadlist&forumid=\$(QUERY_STRING{forumid
> })&page=\$(QUERY_STRING{page})&daysprune=\$(QUERY_STRING{daysprune})&lcid=${
> lcid}&dummy=1"/>
> #end
> 
> The problem I get is that the two escaped $ dont appear at all in the
> output, everything else is OK.
> 
> Anyone know what I am doing wrong?
> 

You are on a roll... :)

That's 3 escaped $, right?

I assume that you wanted the '\$' character sequence to appear literally,
such as

.... \$(QUERY_STRING{forumid})&page....

in the output?

If so, you are 2-0 this morning in bug finding, as this is another bug, and
an odd one at that...

The workaround, for now, is something like

 
 #macro(PanelC $lcid)
#set($sl = '\')
 <esi:include
 src="/servlet/forumManager?action=threadlist&forumid=${sl}$(QUERY_STRING{fo
rumid})&page=${sl}$(QUERY_STRING{page})&daysprune=\$(QUERY_STRING{daysprune}
)&lcid=${lcid}&dummy=1"/>
 #end

Which isn't great, but gets you going.
 


-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
"They that can give up essential liberty to obtain a little temporary safety
deserve neither liberty nor safety." - Benjamin Franklin



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


Re: Visibility of macro with local scope

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 11/19/01 5:34 AM, "Robert Edgar" <ro...@eeplace.com> wrote:

> If I set velocimacro.permissions.allow.inline.local.scope=true then define
> an in line macro and call it as part of a set variable directive with double
> quotes velocity fails to parse the macro.
> 
> ie
> #set($panelC = "#PanelC($lcid)" where #PanelC is an in line macro should
> give the results of the macro but instead the variable panelC is set to the
> text #PanelC not the parsed result...
> 
> 
> I am misunderstanding something...
> 

No, you are right.

It's a bug.  I understand why.  Will fix.


-- 
Geir Magnusson Jr.                       geirm@optonline.net
System and Software Consulting
You're going to end up getting pissed at your software
anyway, so you might as well not pay for it. Try Open Source.



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


Visibility of macro with local scope

Posted by Robert Edgar <ro...@eeplace.com>.
If I set velocimacro.permissions.allow.inline.local.scope=true then define
an in line macro and call it as part of a set variable directive with double
quotes velocity fails to parse the macro.

ie
#set($panelC = "#PanelC($lcid)" where #PanelC is an in line macro should
give the results of the macro but instead the variable panelC is set to the
text #PanelC not the parsed result...


I am misunderstanding something...

Rob


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