In a play framework 1.2.4 Controller, is it possible to get the contents of a template or tag as a String before output to the browser?
I want to be able to do this:
String json = renderAsString("/path/to/template.json", var1, var2);
//then use json as the body of a Play.WS request body.
The solution is based on the assumption that you are talking about PlayFramework 1.x
If you are using Groovy template engine:
And you have a shortcut way if you are using Rythm template engine:
Or you can also use named arguments:
Note the Groovy way also works for Rythm if your template file is put under
app/rythmfolder.