On Tue, 2 Jan 2001, WATKINS, Andy, FM wrote:
> Many of the String variables I place within the template
> cantain &'s and <'s.
>
> In webMacro I can globally force all returned strings to
> be escaped with the #htmlescape directive.
>
> Can I do this in Velocity? Many template engines have HTML
> escaping enabled by default as this is the most useful.
There is an Escape.java class that is currently used
in Anakia to do this. You can simply grab that class
place it in the context and go!
context.put("escape", new Escape());
and use it in your template as
$escape.getText($stringToEscape)
We are planning to move all useful tools into a single
location soon and make them available as a useful set
of context tools and the Escape class will be one
of them.
jvz.