I'm trying to understand ejs filters, but I can't get it working:
Server.js
var ejs = require('ejs');
ejs.filters.test = function() {
//empty for test
};
Routes.js
app.get('/index', function(req, res) {
res.render('index.ejs', {
data : someData
});
});
Index.ejs:
<% test %>
Error:
...test is not defined
at buf.push.__stack.lineno (eval at <anonymous> ....
A filter is applied to some data with the following syntax.
<%=: data | test %>
Where you are missing the =:
and the data to be filtered.