Using Play 2 I am realising a simple REST API, the output is plain text. My template looks like this:
@(items: Map[String,String])
@for((key, value) <- items) {
@value
@key
}
In the controller:
return ok(views.html.bla.render(itemsMap)).as("text/plain");
This gives the following output:
(empty line)
(empty line)
value
key
(empty line)
value
key
I want to get rid of the first 2 empty lines – is that possible?
Putting the for in the first line removes one of the empty lines at the top, however one still remains and for in the first line makes the template hard to read ): Thanks for any hint!
First off, if you use plain text, you should use txt templates (
bla.scala.txt). They also automatically settext/plain; charset=utf-8content type.To trim the content, you can return the rendered content directly:
In case you want to render HTML content you’d need to change this manually: