I am currently trying to dynamically generate Javascript using a Scala object in my Play application, like so:
<script type="text/javascript">@JavascriptGenerator.generateChangingTextScript()</script>
This Javascript contains characters that Play wants to escape automatically, such as a quote ("). It automatically turns it into:
"String goes here"
rather than the desired:
"String goes here"
The Javascript being returned does not like this, and as such does not work. How do I tell Play to not do this?
Thanks.
I am currently trying to dynamically generate Javascript using a Scala object in my Play application, like so:
<script type="text/javascript">@JavascriptGenerator.generateChangingTextScript()</script>
This Javascript contains characters that Play wants to escape automatically, such as a quote ("). It automatically turns it into:
"String goes here"
rather than the desired:
"String goes here"
The Javascript being returned does not like this, and as such does not work. How do I tell Play to not do this?
Thanks.
Share Improve this question edited Apr 26, 2012 at 9:14 4e6 10.8k4 gold badges53 silver badges62 bronze badges asked Apr 26, 2012 at 1:23 GuicerGuicer 1271 silver badge10 bronze badges2 Answers
Reset to default 16The Play 2 equivalent to Play 1’s ${"<".raw}
is @Html("<")
.
In play 1.2.4, there's the methode .raw() that returns the raw content of a property in a template. Did you try @JavascriptGenerator.generateChangingTextScript().raw(); That might work.