[stringtemplate-interest] HTML escaping

Terence Parr parrt at cs.usfca.edu
Fri Jan 18 13:55:43 PST 2008


On Jan 18, 2008, at 1:46 PM, Roman Odaisky wrote:

> Greetings,
>
> I’m looking for a template engine for a future Web project. I really  
> like the
> strict philosophy of StringTemplate, but could you please explain  
> one thing:
>
> The manual says one should use renderers for escaping. That makes  
> sense for
> applications that generate SQL, or C, but how does one use ST for JS  
> embedded
> in HTML? <b>hello $user$</b> and alert("hello $user$") need different
> escaping, and the possible presence of <![CDATA[ complicates things  
> further.

Hi. You can use \$ to escape the $ which usually takes care of it even  
in CDATA.  ST translates to $.

Ter


More information about the stringtemplate-interest mailing list