Frage

(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?

War es hilfreich?

Lösung

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

Andere Tipps

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top