Reputation: 230346
How do I render inline HTML from Play 2, without using an external template file?
def checkStatus = Action {
val status = ...
if (status.ok) {
Ok("Status OK")
} else {
// Oops, this renders the literal text instead of the HTML I wanted:
Ok("Bad status, check out <a href='http://help.us.com/'>our help page</a>")
}
}
Upvotes: 1
Views: 451
Reputation: 55798
When you are rendering the view, Play recognizes its type (at least for html, xml, and txt), but when you want to return common String
you need to instruct which type it is (otherwise it's assumed as text/plain
)
According to Manipaliting response doc you need to return with with the type:
BadRequest("Bad status, check out <a href='http://help.us.com/'>our help page</a>").as("text/html")
Upvotes: 2