質問

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?

役に立ちましたか?

解決

Apparently I needed to use a colon in the opening tag

<?=:

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top