This tool exposes methods to evaluate the given
strings as VTL (Velocity Template Language)
using the given context.
NOTE: These examples assume you have placed an
instance of the current context within itself
as 'ctx'. And, of course, the RenderTool is
assumed to be available as 'render'.
Ok, so these examples are really lame. But, it seems like
someone out there is always asking how to do stuff like this
and we always tell them to write a tool. Now we can just tell
them to use this tool.
This tool is safe (and optimized) for use in the application
scope of a servlet environment.
NOTE: These examples assume you have placed an instance of the current context within itself as 'ctx'. And, of course, the RenderTool is assumed to be available as 'render'.
Example of eval(): Input ----- #set( $list = [1,2,3] ) #set( $object = '$list' ) #set( $method = 'size()' ) $render.eval($ctx, "${object}.$method") Output ------ 3 Example of recurse(): Input ----- #macro( say_hi )hello world!#end #set( $foo = '#say_hi()' ) #set( $bar = '$foo' ) $render.recurse($ctx, $bar) Output ------ hello world!Ok, so these examples are really lame. But, it seems like someone out there is always asking how to do stuff like this and we always tell them to write a tool. Now we can just tell them to use this tool.
This tool is safe (and optimized) for use in the application scope of a servlet environment.