Skip to content

Commit

Permalink
Merge pull request #13 from patchlog/master
Browse files Browse the repository at this point in the history
support template for the text version so nodemailer will generate a m…
  • Loading branch information
yads authored Sep 24, 2021
2 parents dfb6692 + c93354c commit 103ab33
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions lib/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,23 @@ TemplateGenerator.prototype.render = function render(mail, cb) {
if (mail.data.html) return cb();

var templatePath = path.join(this.viewPath, mail.data.template + this.extName);

var textTemplatePath='';
if (!!mail.data.text_template) {
textTemplatePath=path.join(this.viewPath, mail.data.text_template + this.extName);
}
var viewEngine=this.viewEngine;
this.viewEngine.renderView(templatePath, mail.data.context, function(err, body) {
if (err) return cb(err);

mail.data.html = body;
cb();
if(!mail.data.text_template)cb();
else{
viewEngine.renderView(textTemplatePath, mail.data.context, function(err, body) {
if (err) return cb(err);
mail.data.text = body;
cb();
});
}
});
};

module.exports = TemplateGenerator;
module.exports = TemplateGenerator;

0 comments on commit 103ab33

Please sign in to comment.