我正在使用 consolidate.js 和 ractive 模板,默认情况下会去掉注释。我正在尝试在执行以下操作的页面中添加一些 html 逻辑:
<![if IE]>one thing<![endif]>
<![if !IE]>another thing<![endif]>
但是 ractive 删除了评论。我知道你可以通过将 stripComments 设置为 false 来允许评论,但我不知道如何通过 consolidate.js 做到这一点。
的第二个参数consolidate.ractive()
直接传递给 Ractive,所以你可以这样做:
cons.ractive(path, { stripComments: false, user: 'Tobi' }, function () {});
如果你想将你的数据从 Ractive 配置中分离出来,你可以这样做:
cons.ractive(path, { stripComments: false, data: { user: 'Tobi' } }, function () {});
如果对象没有该data
属性,则也将使用整个对象data
。