html 中的 <%- %> 标签是什么意思?

What is the meaning of <%- %> tags in html?

好的,我一直在搜索这个,并在此处找到可能的重复项 (what does " <%: " do?)。但是这个问题针对 <%= 和 <%:,但不是 <%-.

所以只是为了确定我还在问我的问题。

我正在尝试设置一个节点。js/express/d3 在服务器端呈现的应用程序。我在这里找到了一个描述我想做什么的回购协议: https://github.com/gregjopa/d3-server-side-demo/blob/master/index.html

在那 html 代码中有一个片段,我想在 jade 中实际转换:

    <h1>D3 Server-side Demo</h1>

<%-
  barChartHelper.getBarChart({
    data: fixtureData,
    width: 400,
    height: 300,
    xAxisLabel: '2012',
    yAxisLabel: 'Views',
    containerId: 'bar-chart-small'
  })
%>

所以我有两个问题: 1)html中的<%- %>是什么意思? 和 2)我怎么用玉写这个? 谢谢,

您链接的代码库具有 EmbeddedJS 作为依赖项。 EJS 是一个允许使用这些标签的模板库。

Unescaped buffering with <%- code %>

所以基本上:这些不是 HTML 标签,只是属于允许执行内联 JS 代码的不同模板语言的标签

您可以在 Jade 中使用相同的方法,如 docs

中所述

Unescaped Buffered Code

Unescaped buffered code starts with != and outputs the result of evaluating the JavaScript expression in the template.