webmaker-mailroom
v2.1.11
Published
This module outputs **rendered/localized html** for Webmaker emails given a template name, some arbitrary data, and a locale.
Keywords
Readme
Webmaker mailroom
This module outputs rendered/localized html for Webmaker emails given a template name, some arbitrary data, and a locale.

Install
npm install webmaker-mailroomUsage
var mailroom = require('webmaker-mailroom');
// Configure
var templateName = 'badge_awarded';
var data = {
name: 'Kate Hudson',
faveTeam: 'DFB'
};
var options = {
locale: 'en-US',
partial: true
};
var email = mailroom.render(templateName, data, options);
// Output
// email.html: The html of the email body
// email.subject: The subject of the htmlOptions
locale- The locale of the email, defaults toen-US.partial- Only render the body of the email, do not include html headers/footers. Defaults tofalse. Do NOT set this to true if you are passing the email directly tonode-mailer, you want to include the full html.
Development
If you are developing a template, install gulp with npm install -g gulp and simply run:
npm install
gulp devThis will start a watch process, build test files as you make changes, and run a server so you can view them in a browser.
Tests
gulp testAdding a new email template
- Run
gulp new. Choose an appropriate id for your email, e.g.my_awesome_email. - In
templates/my_awesome_email/index.html, create a template. Refer to the nunjucks templating docs for how to add templated data. - In
templates/my_awesome_email/index.js, add a name, description, and some test data for your email. - Run
gulp testto validate your template with the test data you provided, orgulp devto see the email in the browser.
