Skip to content

tutory/email-templates-as-promised

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

email-templates-as-promised

Promisified version of email-templates

Instead of ...

emailTemplates(templatesDir, options, function(err, template) {
  var locals = { pasta: 'Spaghetti' };
  template('pasta-dinner', locals, function(err, html, text) {
    // rendered templates
  });
});

... just do

var render = emailTemplates(templatesDir, options);

var locals = { pasta: 'Spaghetti' };
var pastaDiner = render('pasta-dinner', locals).then(function(res) {
  // rendered templates
  // res == {
  //   html: '',
  //   text: ''
  // }
});

This way render function can easily be exported:

//emails.js

var render = emailTemplates(templatesDir, options);

module.exports.pastaDinner = function(locals) {
  return render('pasta-dinner', locals);
};

// usage

var emails = require('./emails');

emails.pastaDiner({ pasta: 'Spagetti' }).then(function(res) {
  // do something
});

Rendered templates are also cached by templatesDir.

About

Promisified version of email-templates

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published