Question

(Note, this is the Scalate Jade, if that makes a difference)

I have the following route:

get("/fruit") {
  contentType = "text/html"
  jade("fruity", "fruit" -> "apple")
}

And this fruity.jade template:

-@ val fruit: String

p Alerting #{fruit}
:javascript
  alert("#{fruit}");

It renders like so:

<body><p>Alerting apple</p>
<script type="text/javascript">
  //<![CDATA[
    alert("#{fruit}");
  //]]>
</script>
</body>

The fruit value is not interpolated for the javascript portion. How can I get it to resolve in javascript?

Was it helpful?

Solution

I found that :&javascript or :!javascript will work. It is explained here.

OTHER TIPS

If filters are not interpolated, just use a raw :script tag.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top