antlr / stringtemplate4

StringTemplate 4
http://www.stringtemplate.org
Other
955 stars 231 forks source link

Add escaping for ' and " in the StringRenderer "xml-encode" #283

Closed feanor777 closed 3 years ago

feanor777 commented 3 years ago

Is it possible to add encoding for the ' and " inside the StringRenderer class?

It's recommended to always escape these characters, to avoid issues, for example when you're setting value inside of attribute. https://stackoverflow.com/questions/7381974/which-characters-need-to-be-escaped-in-html

Thank you!

parrt commented 3 years ago

Ah. Since I'm more in maintenance mode, can you subclass the renderer and make the changes you want? Then you can register the new kind of object.

feanor777 commented 3 years ago

Thank you for the answer! Yes, I know, it's possible to use your own Renderer class, just was thinking that it would be good to add these things to the default StringRenderer class.