【发布时间】:2012-02-03 14:57:49
【问题描述】:
我在 ejs 中使用 express(node.js 的 web 框架)。现在我想创建自己的过滤器,如ejs github page 所述:
To add a filter simply add a method to the .filters object:
ejs.filters.last = function(obj) {
return obj[obj.length - 1];
};
问题:我如何访问那个 ejs 对象?我已经(天真地)在 app.js 中尝试过:
ejs.filters.myfilter = function (obj) {
....
}
这给了我错误:
ReferenceError: ejs is not defined
【问题讨论】: