Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Escaping HTML in a Java Play Framework Scala Template

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?

like image 554
slifty Avatar asked Mar 10 '13 04:03

slifty


1 Answers

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

like image 148
Marius Soutier Avatar answered Nov 17 '22 14:11

Marius Soutier