TextTemplates and out/print binding

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

TextTemplates and out/print binding

The documentation seems to suggest that TextTemplate module uses the groovy  SimpleTemplate engine (and the Learning Ratpack book certainly links there) but the behaviour seems to be more like GStringTemplate or StreamingTemplateEngine but a quick look at the code suggests it might just be using manual ScriptCompilation.

All the engine types have example of how to explicitly write to the writer that the template is being written to:

<% print city == "New York" ? "The Big Apple" : city %>

<% out << (city == "New York" ? "\\"The Big Apple\\"" : city) %>

<% out.print firstname %>

But none of these seem to work inside a ratpack TextTemplate. Any ideas how to write explicitly to the template writer (for example inside a .each closure on a model object):

<% model.things.each{ ????????? "($it.id) $it.name <br/>"} %>