解决了:https: //github.com/balderdashy/sails/issues/2162#issuecomment-55866731
配置/ http.js
module.exports.http = {
// ...
locals: {
filters: {
formatDate: function(date) { }
}
}
}
Run Code Online (Sandbox Code Playgroud)
配置/ bootstrap.js
_.extend(sails.hooks.http.app.locals, sails.config.http.locals);
Run Code Online (Sandbox Code Playgroud)
在某些观点......
意见/ test.ejs
<%=: created | formatDate %>
Run Code Online (Sandbox Code Playgroud)
实现此目的的一种方法是通过中间件。就像是:
module.exports.routes = {
'*': function mixinForm(req, res, next) {
// <%= form() %>
res.locals.form = function () {
return '<form action=""></form>';
};
next();
},
}
Run Code Online (Sandbox Code Playgroud)
我还建议在以下位置提出功能请求,以采用更集成的方法:https://trello.com/b/cGzNVE0b/sails-js-feature-requests。
| 归档时间: |
|
| 查看次数: |
2969 次 |
| 最近记录: |