Probably hard if not impossible with the Scala templates.
In case you would consider alternate template engine, I added the support to Japid42 (
https://github.com/branaway/japid42) yesterday, so one can do something like the following in a controller:
public static Result dynamic() {
String template = "@(String s, int i)\nHi ${s}, are you ${i} years old?";
return ok(renderDynamic(template, "Johnny", 13));
}
The dynamic inline script is compiled to jvm bytecode and cached. It can use whatever other templates (tags, etc) on your harddrive.
Remember though, the dynamic scripts must be managed in your hands, or you risk exposing the runtime system to attackers.