TextTemplates and out/print binding

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

TextTemplates and out/print binding

parker0phil
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:

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

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

StreamingTemplateEngine
<% 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/>"} %>

Loading...