문제

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

도움이 되었습니까?

해결책

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

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top