I'm trying to render a pug/jade template with node email templates.
var confirmCode = generateConfirmCode(configPublic.confirmCodeLength);
var query = querystring.stringify({
code: confirmCode,
id: user._id.toString()
});
var templateDir = path.join(__dirname, '../templates', 'confirmation-email');
var confirmEmail = new EmailTemplate(templateDir);
var confirmUrl = configPublic.url + '/user/email/confirm?' + query;
var templateVals = {url: confirmUrl};
confirmEmail.render(templateVals, function(err, result) {
if (err) {
console.log(err);
}
var mailOptions = {
from: configPrivate.gmail.username,
to: user.email.address,
subject: 'confirmation',
html: result.html
};
email.send(mailOptions)
.then(function (successMsg) {
db.setConfirmCode(user, confirmCode)
.catch(function (err) { // catch setConfirmCode err
deferred.reject(err);
});
deferred.resolve(successMsg);
})
.catch(function (err) { // catch send err
deferred.reject(err);
})
So I pass templateVals
to the render call, and I'm trying to figure out how to display that information on the rendered template like so:
link(rel='stylesheet', href='./style.css')
|
|
p !{url}
p #{url}
p url
p templateVals.url
p #{templateVals.url}
p !{templateVals.url}
and none of these combinations seem to be working. I'm not sure what I'm doing wrong here. Thanks for your help!
Ended up not being an issue with the code, but with the webstorm file watcher putting an html file in the
email-templates
template directory causing the render to fail