Thursday, April 30, 2009

Adding Velocity tools to a velocity context

I could not find a basic example on how to add the Velocity tools library (in my case the EscapeTool) so I can use these helping routinged in my templates.

So here is mine:

org.apache.velocity.tools.generic.EscapeTool escTool = new org.apache.velocity.tools.generic.EscapeTool();

velocityContext.put("esc",escTool);

you can then call in your templates $esc.html($text_to_be_escaped)

I hope it helps

http://velocity.apache.org

No comments: