5

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:

&quot;String goes here&quot;

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.

2 Answers 2

16

The Play 2 equivalent to Play 1’s ${"<".raw} is @Html("<").

Sign up to request clarification or add additional context in comments.

Comments

0

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.

1 Comment

I tried that before asking this question; sorry for not indicating as such. At any rate, it broke the program. I guess that's deprecated, or I need a particular import to use it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.