Re: macro fails to access param properties with render.eval

Jonathan Ihm <[email protected]>
Newsgroups gmane.comp.jakarta.velocity.user
Message-ID <CAAKJkPTWtrcdtFKqaUb7Q-4ShgnjpyNZVDv7zTddKQbxvm0rrA@mail.gmail.com>
You are calling a method on a string.  When you put $p1 between the single
quotes, you are not using whatever object $p1 is, but the literal string
'$p1' and getId() is not a method for a string.

Also, it works fine for me when I run #aMacro($p1) with a dummy object, but
not setting macroName and call variables.  Are those necessary?  Try this:

#aMacro($p1)




On Fri, Apr 12, 2013 at 12:46 AM, kris <[email protected]> wrote:

> My VTL template looks like:
> #macro(aMacro $par1)
>         ##$par1
>         $par1.getId()
> #end
>
> #set($macroName = "aMacro")
> #set( $call = "#$macroName('$p1')" )
> #evaluate($call)
>
> I have filled the context with an object that has Id property. When I run
> this template I would like to see the Id of the object. Instead it just
> outputs "$par1.getId()"
>
>
>
> --
> View this message in context:
> http://velocity.10973.n7.nabble.com/macro-fails-to-access-param-properties-with-render-eval-tp16194.html
> Sent from the Velocity - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.