You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by Jason Dillon <ja...@planet57.com> on 2007/02/09 00:45:32 UTC
How to get Velocity to work better with Groovy?
<note>
No answer from the velocity folks, so I'll try here...
</note>
Hi, I'm trying to get Velocity to work better with Groovy objects,
like Expando and other more dynamic objects.
In groovy one can:
def data = new Expando()
data.foo = 'bar'
This will dynamically create new properties on the object 'data'.
But, if you pass that 'data' object to Velocity in a context, then a
template like:
<snip>
$data.foo
</snip>
Will simply render:
<snip>
$data.foo
</snip>
As it was unable to de-reference the 'foo' property.
* * *
I like Groovy, and I like Velocity, but I would like them to play
better together.
Is there any mechanism in Velocity to get more control over how it
evaluates bits like "$data.foo"? Or perhaps, if 'data' is in the
context, then more control over how Velocity finds the 'foo' property
of the object which is bound to the 'data' name? I guess the same
would also go for finding methods on objects bound in the context.
Any help is appreciated. Thanks,
--jason