With Ratpack 1.6.1 I have a gtpl template with a div element as follows:
div('<pre>HELLO</pre>')
Ratpack doesn't escape the inner pre element even though autoEscape is true. Is there a way to fix/workaround the issue?
P.S. autoEscape in TemplateConfiguration is true by default. Setting it to true explicitly doesn't help too:
module(MarkupTemplateModule) { TemplateConfiguration config ->
config.baseTemplateClass = MarkupTemplateExtensions
config.autoEscape = true
}
Finally figured out the answer:
autoEscapedoesn't enable escaping in templates. It only enables escaping data passed directly intogroovyMarkupTemplatelike that:Solution
In order to enable escaping in all templates by default, it's necessary to subclass
BaseTemplatelike that:Apply our own template processor in Ratpack.groovy
Subclass BaseTemplate and override methodMissing():