Jac*_*łło 3 node.js swig-template sails.js
我想将默认Swig tagControls {%...%}更改为{?...?}我正在使用sails.js框架.
我添加到配置文件夹swig.js文件,其中包含:
module.exports.swig = {
SwigOpts: {
'tagControls': ['{?', '?}']
}
};
Run Code Online (Sandbox Code Playgroud)
但它不起作用,浏览器中的视图如下所示:
{? for user in users ?}
{? user.email ?}
{? endfor ?}
Run Code Online (Sandbox Code Playgroud)
所以,标签没有被解释.我的配置文件错了吗?标准代码{%...&}运行正常.
这样的事情应该有效:在你的 config/views.js
engine: {
ext: 'swig', // Or `html`, whatever you are using
fn: function (pathName, locals, cb) {
var swig = require('swig');
swig.setDefaults({tagControls: ['{?', '?}']});
return swig.renderFile(pathName, locals, cb);
}
},
Run Code Online (Sandbox Code Playgroud)
至于config/swig.js和module.exports.swig,我不认为它是自动处理的.
| 归档时间: |
|
| 查看次数: |
1646 次 |
| 最近记录: |