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

How to use context objects in hbs and iterations of array of objects #55

Open
ajithv11 opened this issue Apr 19, 2022 · 0 comments
Open

Comments

@ajithv11
Copy link

I need to iterate my orders in my .hbs template. My code is given below
`
var nodemailer = require('nodemailer');
var mailerhbs = require('nodemailer-express-handlebars');
let transporter = nodemailer.createTransport({
host: CONSTANT.SMTPHOST,
port: 587,
secure: false,
auth: {
user: CONSTANT.SMTPUSER,
pass: CONSTANT.SMTPPASSWORD,
},
});

transporter.use('compile', mailerhbs({
viewEngine: {
extname: '.hbs',
partialsDir: templatePath,
layoutsDir: templatePath+'/layouts',
defaultLayout: 'blank',
},
viewPath: templatePath,
extName: '.hbs'
}))

`
The problem is that in the mail context I can add access strings only in the hbs template

mailData.context = { orderId : 'testid', // This works user : user // This is object accessing user._id not working in hbs file };
Error I got is given below
Handlebars: Access has been denied to resolve the property "_id" because it is not an "own property" of its parent.
You can add a runtime option to disable the check or this warning:
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details

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

1 participant