Using Play Framework 2 I\'ve noticed the rendered Scala HTML templates don\'t like indented @if
or @for
.
So, for example, something like that:<
Of course there is always some option :), trim the body and set header again so (cause after operations on the String it will be returned as text/plain
):
// instead of
return ok(index.render("some"));
// use
return ok(index.render("some").body().trim()).as("text/html; charset=utf-8");
for 'beauty' loops or if's you need to write more compact code
// instead of
@for(test <- tests) {
- @test.name
}
// use
@for(test <- tests) {- @test.name
}
And finally you can use some compressor (ie. com.googlecode.htmlcompressor) to... minify whole page (in this sample for production mode only)
String output = index.render("some").body().trim();
if (Play.isProd()) output = compressor.compress(output);
return ok(output).as("text/html; charset=utf-8");