【问题标题】:Jade interpolation within javascriptjavascript中的Jade插值
【发布时间】:2013-04-16 05:30:02
【问题描述】:

(注意,这是鳞片翡翠,如果有区别的话)

我有以下路线:

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

还有这个fruity.jade 模板:

-@ val fruit: String

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

呈现如下:

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

fruit 值未插入到 javascript 部分。我怎样才能让它在 javascript 中解析?

【问题讨论】:

    标签: pug scalatra scalate


    【解决方案1】:

    我发现:&amp;javascript:!javascript 可以工作。解释为here

    【讨论】:

    • 非常有趣!但是,我认为官方编译器不支持它
    • 仅供参考,here 是一个更新的文档链接(原来的似乎不再有效)。
    【解决方案2】:

    如果没有插入过滤器,则只需使用原始的:script 标记。

    【讨论】:

      猜你喜欢
      • 2016-08-07
      • 1970-01-01
      • 2015-04-19
      • 2016-12-17
      • 1970-01-01
      • 1970-01-01
      • 2016-12-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多