html markup in Play Framework messages

2020-07-13 12:02发布

问题:

I'm using the Internationalisation messages file in Play. In my messages.en file I have:

support.msg=Click here to contact <a href="support.html">support</a>

but this gets output as

&lt;a href=&quot;support.html&quot;&gt;support&lt;/a&gt;

Is it possible to escape html in messages.en file so they are output 'as is'

回答1:

By default, Play! automatically escapes strings used in a view. If you'd like to output raw text (including the HTML), wrap the variable in Html().

Example from the docs:

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