You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by Llewellyn Falco <is...@setgame.com> on 2005/08/30 01:34:27 UTC
escaping velocity
interesting escaping rule...
\$object.method()
could parse to
\$object.method()
$object.method()
depending on weather or not method is defined...
which brings an interesting question.
i want to generate a velocity template.
final result looks like
---
$object.getMethod()
---
i have context
put("methods", "Method")
i could write
\$object.get${methods}()
but since $object.get is undefined, this would parse to
\$object.getMethod()
which be what i want.
of course i could do
$object.get${methods}()
but that's a syntax error.
so any suggestion?
llewellyn.
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
Re: escaping velocity
Posted by Will Glass-Husain <wg...@forio.com>.
There's a bug or two with the escaping. see
http://issues.apache.org/bugzilla/show_bug.cgi?id=28528
Eventually we'll dig into this.
Try following Nathan's suggestion, but bear in mind you might be hitting
this item or a variant.
WILL
----- Original Message -----
From: "Nathan Bubna" <nb...@gmail.com>
To: "Velocity Developers List" <ve...@jakarta.apache.org>; "Llewellyn
Falco" <is...@setgame.com>
Sent: Monday, August 29, 2005 5:10 PM
Subject: Re: escaping velocity
i'm not sure why $object.get${methods}() is giving you a syntax error.
if there is no "getGet", "getget", or get("get") method for your
$object, then you should still get $object.getMethod() in your output
(though that will trigger an invalid reference message in your logs).
anyway, if you have done ctx.put("methods", "Method") and do the
following in your template...
#set( $D = '$' )
${D}object.get${methods}()
then you should get...
$object.getMethod()
after your first pass (with no invalid reference messages).
if you are still getting a syntax error, then perhaps parser is
(wrongly) bothered by the parentheses. in that case, try
#set( $D = '$' )
#set( $PS = '()' )
${D}object.get${methods}${PS}
On 8/29/05, Llewellyn Falco <is...@setgame.com> wrote:
> interesting escaping rule...
>
> \$object.method()
>
> could parse to
> \$object.method()
> $object.method()
>
> depending on weather or not method is defined...
>
> which brings an interesting question.
> i want to generate a velocity template.
> final result looks like
> ---
> $object.getMethod()
> ---
> i have context
> put("methods", "Method")
>
>
> i could write
> \$object.get${methods}()
> but since $object.get is undefined, this would parse to
> \$object.getMethod()
> which be what i want.
>
> of course i could do
> $object.get${methods}()
>
> but that's a syntax error.
>
> so any suggestion?
>
>
>
> llewellyn.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
Re: escaping velocity
Posted by Nathan Bubna <nb...@gmail.com>.
i'm not sure why $object.get${methods}() is giving you a syntax error.
if there is no "getGet", "getget", or get("get") method for your
$object, then you should still get $object.getMethod() in your output
(though that will trigger an invalid reference message in your logs).
anyway, if you have done ctx.put("methods", "Method") and do the
following in your template...
#set( $D = '$' )
${D}object.get${methods}()
then you should get...
$object.getMethod()
after your first pass (with no invalid reference messages).
if you are still getting a syntax error, then perhaps parser is
(wrongly) bothered by the parentheses. in that case, try
#set( $D = '$' )
#set( $PS = '()' )
${D}object.get${methods}${PS}
On 8/29/05, Llewellyn Falco <is...@setgame.com> wrote:
> interesting escaping rule...
>
> \$object.method()
>
> could parse to
> \$object.method()
> $object.method()
>
> depending on weather or not method is defined...
>
> which brings an interesting question.
> i want to generate a velocity template.
> final result looks like
> ---
> $object.getMethod()
> ---
> i have context
> put("methods", "Method")
>
>
> i could write
> \$object.get${methods}()
> but since $object.get is undefined, this would parse to
> \$object.getMethod()
> which be what i want.
>
> of course i could do
> $object.get${methods}()
>
> but that's a syntax error.
>
> so any suggestion?
>
>
>
> llewellyn.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org