RenderTool Reference Documentation

This tool exposes methods to evaluate the given strings as VTL (Velocity Template Language) and automatically using the current context.

@@@version@@@, @@@date@@@org.apache.velocity.tools.generic.RenderTool$renderNathan Bubna<tool> <key>render</key> <scope>application</scope> <class>org.apache.velocity.tools.generic.RenderTool</class> </tool>The Javadoc for more info.

eval()

Evaluates a String containing VTL using the current context, and returns the result as a String. String eval(Context ctx, String vtl) The Context to be evaluate the vtl with. The code to be evaluated. The evaluated code as a String.

Evaluates a String containing VTL using the given context, and returns the result as a String. If this fails, then null will be returned. This evaluation is not recursive.

#set( $list = [1,2,3] ) #set( $object = '$list' ) #set( $method = 'size()' ) $render.eval($ctx, "${object}.$method")

This will produce the following output:

3

recurse()

Recursively evaluates a String containing VTL using the current context, and returns the result as a String. String recurse(Context ctx, String vtl) The code to be evaluated. The Context to be evaluate the vtl with. The evaluated code as a String.

Recursively evaluates a String containing VTL using the given context, and returns the result as a String. It will continue to re-evaluate the output of the last evaluation until an evaluation returns the same code that was fed into it.

#macro( say_hi )hello world!#end #set( $foo = '#say_hi()' ) #set( $bar = '$foo' ) $render.recurse($ctx, '$bar')

This will produce the following output:

hello world!