[stringtemplate-interest] html escaping
Terence Parr
parrt at cs.usfca.edu
Fri Nov 4 09:37:00 PST 2005
On Nov 3, 2005, at 7:14 PM, polina orechko wrote:
> Hello,
>
> I am integrating StringTemplate as a template engine in a Struts-
> based web app.
>
> One of the questions I have is about HTML escaping, such as
> converting <, >, quotes, etc. into their HTML entity equivalents
> such as < > etc..
>
> As far as I can see from the source code, StringTemplate does not
> provide such an option out of the box, is this understanding correct?
Correct; ST is really target language neutral.
> One way to do this would be to provide a String getter that would
> return an encoded String, which quite cumbersome.
>
> The second question is whether providing a render for String.class
> via StringTemplate.registerRenderer looks like a better solution?
> Would it work well? Are there any hidden caveats or problems that
> may surface?
It *should* work. ;) I think somebody found a bug (with patch on
this list) recently. I fixed in mainline for 2.3.
Best regards and thanks for using ST!
Ter
More information about the stringtemplate-interest
mailing list