Lilluda 5
Lilluda 5

Reputation: 1109

Rendering Html Variables in Scala Play controller/template

I have a Scala Play web app that is pulling html variables from the database, then placing them inside of a template. Something like this

<div>@myvar</div>

Where my var is an html string. The myvar is not being recongized by the template engine as html. So I get an output something like this

<h3>MY HEADING</h3>

instead of the h3 tags being rendered by the Scala play template engine to a proper html H3 tag.

Where do I need to render these variables? I have tried to do it in my controller but have obviously failed.

Thanks!

Upvotes: 1

Views: 549

Answers (1)

Michael Zajac
Michael Zajac

Reputation: 55569

You need to wrap it in an Html object, otherwise the html is escaped.

<div>@Html(myvar)</div>

Upvotes: 5

Related Questions