javascript - 在 Jade 模板中打印注释内的表达式值

标签 javascript node.js express pug

需要打印 Jade 模板注释中的参数值。值传入正确;以下内容按预期工作:

if type !== "surveyFree"
    ul.pollOptions
        for answer, idx in answers
            li
                +printAnswer(answer, idx)
else
    textarea(cols="50", rows="4", placeholder="Type in your answer")

但是,所有打印注释中 type 变量值的尝试都失败了。我尝试过以下形式:

// "type = " + type
// #{"type = " + type}
// span= #{"type = " + type}
// span= type = #{type}

还有许多其他的,但没有任何效果(所有内容都按照我输入的内容准确打印)。我想要输出:

<!-- type = challenge -->

<!-- type = survey -->

感谢所有帮助!

最佳答案

也许这种方式对你有好处:

!='<!-- COMMENT VARAIBLE: ' + variable + '-->'

关于javascript - 在 Jade 模板中打印注释内的表达式值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33050625/

相关文章:

javascript - Node.js 进度指示器反馈

node.js - 模板/渲染 - 如何为我的 View 之一排除或指定备用layout.mustache?

javascript - NodeJS,MIME 类型 ('text/html' )不是受支持的样式表 MIME 类型

node.js - NodeJS Express Windows 最大连接数设置

javascript - 如何获取按钮单击事件的输入的当前值

javascript - 集中 Kendo 验证器自定义规则

javascript - 列表中最短的单词 - JS

node.js - 带循环的 Mongodb 聚合管道

javascript - Fabric js : fabric js drawing mode and selection mode options

node.js - Sequelize : Unhandled rejection TypeError: admin. hasOperation_sav 不是函数