5

Using a Scala template within the Java Play framework 2.0, I want to output dynamic content as HTML encoded.

For example:

<script type="text/javascript">
    $("#@field.getId()").fieldList({
        data: "@myUnencodedData"
    })
</script>

Are there built in methods to accomplish this?

slifty
  • 13,062
  • 13
  • 71
  • 109

1 Answers1

17

By default, HTML is escaped for security reasons. To output HTML, you wrap it in the Html helper: @Html(myUnencodedData).

Marius Soutier
  • 11,184
  • 1
  • 38
  • 48