This module outputs rendered/localized html for Webmaker emails given a template name, some arbitrary data, and a locale
Перейти к файлу
Chris DeCairos d28ffcdb3c test on a recent version of nodejs 2018-10-31 15:22:13 -04:00
base Try some changes 2015-11-20 09:40:43 -05:00
gulp Add support for testing localized emails 2015-11-11 13:45:12 -05:00
locale Merge pull request #69 from mozilla/update-receipt-translations 2018-10-03 11:19:33 +00:00
templates Merge pull request #66 from mozilla/recurring-subject 2018-10-03 11:18:28 +00:00
test Styled Login and reset emails 2014-10-16 12:38:27 -04:00
.gitignore remove locale from gitignore 2015-07-21 17:43:21 -04:00
.travis.yml test on a recent version of nodejs 2018-10-31 15:22:13 -04:00
README.md Updated readme 2014-09-18 14:54:38 -04:00
gulpfile.js Added subject to metadata 2014-09-18 14:54:38 -04:00
index.js localize recurringSubject, add package-lock 2018-10-31 15:17:17 -04:00
jbuckmail.png Added important pic 2014-06-18 12:42:02 -04:00
package-lock.json localize recurringSubject, add package-lock 2018-10-31 15:17:17 -04:00
package.json 2.1.5 2018-04-19 13:45:53 -04:00

README.md

Webmaker mailroom

This module outputs rendered/localized html for Webmaker emails given a template name, some arbitrary data, and a locale.

jbuck the mailman

Install

npm install webmaker-mailroom

Usage

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 html

Options

  • locale - The locale of the email, defaults to en-US.
  • partial - Only render the body of the email, do not include html headers/footers. Defaults to false. Do NOT set this to true if you are passing the email directly to node-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 dev

This 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 test

Adding a new email template

  1. Run gulp new. Choose an appropriate id for your email, e.g. my_awesome_email.
  2. In templates/my_awesome_email/index.html, create a template. Refer to the nunjucks templating docs for how to add templated data.
  3. In templates/my_awesome_email/index.js, add a name, description, and some test data for your email.
  4. Run gulp test to validate your template with the test data you provided, or gulp dev to see the email in the browser.