Closed Tomdrouv1 closed 5 years ago
I'm seeing this also. Looks like there was a change in express-handlebars
which nodemailer-express-handlebars
depends on. See here.
I managed to get my code working, posting in case it helps out. I had to add the partialsDir
to my handlebarOptions
where I didn't have the field before:
const handlebarOptions = {
viewEngine: {
extName: '.hbs',
partialsDir: 'some/path',
layoutsDir: 'some/path',
defaultLayout: 'email.body.hbs',
},
viewPath: 'some/path',
extName: '.hbs',
};
transporter.use('compile', hbs(handlebarOptions));
The partialsDir
must have been an optional field at one point, but now seems to be required. Hope this helps.
I managed to get my code working, posting in case it helps out. I had to add the
partialsDir
to myhandlebarOptions
where I didn't have the field before:const handlebarOptions = { viewEngine: { extName: '.hbs', partialsDir: 'some/path', layoutsDir: 'some/path', defaultLayout: 'email.body.hbs', }, viewPath: 'some/path', extName: '.hbs', }; transporter.use('compile', hbs(handlebarOptions));
The
partialsDir
must have been an optional field at one point, but now seems to be required. Hope this helps.
Works for me thanks a lot now the partialsDir is required i just put it on code and BANG worked ! , thanks again !
I managed to get my code working, posting in case it helps out. I had to add the
partialsDir
to myhandlebarOptions
where I didn't have the field before:const handlebarOptions = { viewEngine: { extName: '.hbs', partialsDir: 'some/path', layoutsDir: 'some/path', defaultLayout: 'email.body.hbs', }, viewPath: 'some/path', extName: '.hbs', }; transporter.use('compile', hbs(handlebarOptions));
The
partialsDir
must have been an optional field at one point, but now seems to be required. Hope this helps.
works for me using partialsDir, thanks
Incase anyone wonders why it still doesn't work, check out this last line, take note of the hbs function
transporter.use('compile', hbs(handlebarOptions));
and change it to mailerhbs
transporter.use('compile', mailerhbs(handlebarOptions));
I managed to get my code working, posting in case it helps out. I had to add the
partialsDir
to myhandlebarOptions
where I didn't have the field before:const handlebarOptions = { viewEngine: { extName: '.hbs', partialsDir: 'some/path', layoutsDir: 'some/path', defaultLayout: 'email.body.hbs', }, viewPath: 'some/path', extName: '.hbs', }; transporter.use('compile', hbs(handlebarOptions));
The
partialsDir
must have been an optional field at one point, but now seems to be required. Hope this helps.
Works for me too, using the partialDir. Thanks!
I managed to get my code working, posting in case it helps out. I had to add the
partialsDir
to myhandlebarOptions
where I didn't have the field before:const handlebarOptions = { viewEngine: { extName: '.hbs', partialsDir: 'some/path', layoutsDir: 'some/path', defaultLayout: 'email.body.hbs', }, viewPath: 'some/path', extName: '.hbs', }; transporter.use('compile', hbs(handlebarOptions));
The
partialsDir
must have been an optional field at one point, but now seems to be required. Hope this helps.
works
I managed to get my code working, posting in case it helps out. I had to add the
partialsDir
to myhandlebarOptions
where I didn't have the field before:const handlebarOptions = { viewEngine: { extName: '.hbs', partialsDir: 'some/path', layoutsDir: 'some/path', defaultLayout: 'email.body.hbs', }, viewPath: 'some/path', extName: '.hbs', }; transporter.use('compile', hbs(handlebarOptions));
The
partialsDir
must have been an optional field at one point, but now seems to be required. Hope this helps.
It works. But when I used different template to send email. The default template still used. My code:
var handlebarsOptions = {
viewEngine: {
extName: '.html',
partialsDir: path.resolve('./views/templates/'),
layoutsDir: path.resolve('./views/templates/'),
defaultLayout: 'forgot-password-email.html',
},
viewPath: path.resolve('./views/templates/'),
extName: '.html'
};
smtpTransport.use('compile', hbs(handlebarsOptions));
var data = {
from: process.env.EMAIL,
to: user.email,
template: 'reset-password-success-email',
subject: 'Password Reset Confirmation',
context: {
name: user.name
}
};
smtpTransport.sendMail(data);
Please help.
I managed to get my code working, posting in case it helps out. I had to add the
partialsDir
to myhandlebarOptions
where I didn't have the field before:const handlebarOptions = { viewEngine: { extName: '.hbs', partialsDir: 'some/path', layoutsDir: 'some/path', defaultLayout: 'email.body.hbs', }, viewPath: 'some/path', extName: '.hbs', }; transporter.use('compile', hbs(handlebarOptions));
The
partialsDir
must have been an optional field at one point, but now seems to be required. Hope this helps.It works. But when I used different template to send email. The default template still used. My code:
var handlebarsOptions = { viewEngine: { extName: '.html', partialsDir: path.resolve('./views/templates/'), layoutsDir: path.resolve('./views/templates/'), defaultLayout: 'forgot-password-email.html', }, viewPath: path.resolve('./views/templates/'), extName: '.html' }; smtpTransport.use('compile', hbs(handlebarsOptions)); var data = { from: process.env.EMAIL, to: user.email, template: 'reset-password-success-email', subject: 'Password Reset Confirmation', context: { name: user.name } }; smtpTransport.sendMail(data);
Please help.
I had the same issue, just set the defaultLayout to an empty string and it'll depend on the template in the mailoptions:
const handlebarOptions = {
viewEngine: {
extName: '.hbs',
partialsDir: 'some/path',
layoutsDir: 'some/path',
defaultLayout: '',
},
viewPath: 'some/path',
extName: '.hbs',
};
transporter.use('compile', hbs(handlebarOptions));
I managed to get my code working, posting in case it helps out. I had to add the
partialsDir
to myhandlebarOptions
where I didn't have the field before:const handlebarOptions = { viewEngine: { extName: '.hbs', partialsDir: 'some/path', layoutsDir: 'some/path', defaultLayout: 'email.body.hbs', }, viewPath: 'some/path', extName: '.hbs', }; transporter.use('compile', hbs(handlebarOptions));
The
partialsDir
must have been an optional field at one point, but now seems to be required. Hope this helps.Works for me too, using the partialDir. Thanks!
Hi can you show me what you put in the viewPath on your project?
I managed to get my code working, posting in case it helps out. I had to add the
partialsDir
to myhandlebarOptions
where I didn't have the field before:const handlebarOptions = { viewEngine: { extName: '.hbs', partialsDir: 'some/path', layoutsDir: 'some/path', defaultLayout: 'email.body.hbs', }, viewPath: 'some/path', extName: '.hbs', }; transporter.use('compile', hbs(handlebarOptions));
The
partialsDir
must have been an optional field at one point, but now seems to be required. Hope this helps.It works. But when I used different template to send email. The default template still used. My code:
var handlebarsOptions = { viewEngine: { extName: '.html', partialsDir: path.resolve('./views/templates/'), layoutsDir: path.resolve('./views/templates/'), defaultLayout: 'forgot-password-email.html', }, viewPath: path.resolve('./views/templates/'), extName: '.html' }; smtpTransport.use('compile', hbs(handlebarsOptions)); var data = { from: process.env.EMAIL, to: user.email, template: 'reset-password-success-email', subject: 'Password Reset Confirmation', context: { name: user.name } }; smtpTransport.sendMail(data);
Please help.
I had the same issue, just set the defaultLayout to an empty string and it'll depend on the template in the mailoptions:
const handlebarOptions = { viewEngine: { extName: '.hbs', partialsDir: 'some/path', layoutsDir: 'some/path', defaultLayout: '', }, viewPath: 'some/path', extName: '.hbs', };
transporter.use('compile', hbs(handlebarOptions));
It did work. Thanks
Hi,
I'm facing an issue for 2 weeks now when I'm using this library in my project hosted in Firebase.
This function works well in local environment and worked well before but now this issue appears, like if my path in the handlebars configuration disappears.
templateDir is a string of course but in the Firebase Functions console the issue “A partials dir must be a string or config object” appears.
Any idea of what it may be?
Thanks