Saqib Ali
Saqib Ali

Reputation: 4448

Adding HTML tags to Scala Play output

I am trying to bold certain phrases in a Play template output, but all it does is output the HTML tag:

@signs.map {sign =>
            <tr>
            <td>@sign(2).replaceAll(phrase, "<b>" + phrase + "</b>") <strong>(@sign(0) : @sign(1) - @sign(3))</strong> </td>
            </tr>
            }

Upvotes: 0

Views: 594

Answers (1)

danielnixon
danielnixon

Reputation: 4268

From https://www.playframework.com/documentation/2.5.x/ScalaTemplates#Escaping:

Escaping

By default, dynamic content parts are escaped according to the template type’s (e.g. HTML or XML) rules. If you want to output a raw content fragment, wrap it in the template content type.

For example to output raw HTML:

<p>
  @Html(article.content)
</p>

Upvotes: 2

Related Questions