Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

you can not render a difeerent template when define defaultLayout #34

Open
yjarid opened this issue Jan 3, 2020 · 2 comments
Open

you can not render a difeerent template when define defaultLayout #34

yjarid opened this issue Jan 3, 2020 · 2 comments

Comments

@yjarid
Copy link

yjarid commented Jan 3, 2020

i have a simple set up , so I define the defaultLayout to be 'resetPassword' and I exported the mailOptions alowing me to customize its parameters, so this setup is working fine at the exception of the template parameters, even when I change it the email is always sent with the defaultLayout template.

PS: I manged to workaroud this issue by setting the defaultLayout to false , but I am hoping there is a better solution

import nodemailer from 'nodemailer'
import hbs from 'nodemailer-express-handlebars'


export const transporter = nodemailer.createTransport({
    service: 'gmail',
    auth: {
        user: process.env.EMAIL,
        pass: process.env.PASS
    }
})



transporter.use('compile', hbs({
    viewEngine: {
        extName: '.handlebars',
        partialsDir:  "mail/views",
        layoutsDir:  "mail/views",
        defaultLayout: 'resetPassword',
    },
    viewPath: 'mail/views/',
    extName: '.handlebars'
}))

export const mailOptions = (to, template , subject, context) => ({
    from : '[email protected]',
    to,
    subject,
    template ,
    context 
})


@tristanguerin
Copy link

+1
I have the same problem and had to set defaultLayout to false

@milad2golnia
Copy link

+1 I have the same problem and had to set defaultLayout to false

Thank you, Your solution was working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants