yads / nodemailer-express-handlebars

A plugin for nodemailer that uses express-handlebars view engine to generate emails
87 stars 30 forks source link

Date helper #4

Closed jrgonzalezrios closed 9 years ago

jrgonzalezrios commented 9 years ago

Hi! I am trying to use a helper to format the date in a email, I tryed this:

var exphbs = require('express-handlebars');

exphbs.create({ // Specify helpers which are only registered on this instance. helpers: { formatDate: function (dateTime) { return moment(dateTime).format('lll '); }
} });

It throws a: Missing helper error. Could you help me how to apply this kind of helper?

Thanks!

yads commented 9 years ago

Yes, when you add the transport mechanism, you can use your express-hbs instance like so:

var exphbs = require('express-handlebars');
...
var hbs = require('nodemailer-express-handlebars');
transporter.use('compile', hbs({
   viewEngine: exphbs,
   ...
));