If I generate some Javascript in my Scala code like this:
<script type="text/javascript">
foo("{bar}");
</script>
and the Javascript contains a double quote character (like in the example), it will appear as "
when the XML is converted into a string, and Firefox will reject this Javascript as having a syntax error.
How can I avoid this Javascript error, without removing "
s that are actually needed?
I'm using Play framework 1.2.4 with the Scala module 0.9.1, which requires Scala 2.8.1.
would something like this work for you?
scala> val bar=scala.xml.Unparsed(""""hello"""")
bar: scala.xml.Unparsed = "hello"
scala> val x = <script type="text/javascript">foo({bar});</script>
x: scala.xml.Elem = <script type="text/javascript">foo("hello");</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With