Reputation: 9700
I have created a custom ejs filter following this SO Question
I created the file in /config and added my filter:
var ejs = require('ejs');
var moment = require('moment');
ejs.filters.formatDate = function (date) {
return moment.date(date).format('dd mm yy hh:ii');
};
ejs.open = '<?';
ejs.close = '?>';
However, when using the filter in the ejs template I get the error that formatDate is not defined. I am using like so:
<?= child.lastPost.createdAt | formatDate ?>
Anyone know where I went wrong?
Upvotes: 2
Views: 934