Skip to content

Instantly share code, notes, and snippets.

@metasansana
Created June 26, 2014 23:47
Show Gist options
  • Save metasansana/d043fbeb3338c5ab1622 to your computer and use it in GitHub Desktop.
Save metasansana/d043fbeb3338c5ab1622 to your computer and use it in GitHub Desktop.
Render email templates with nunjucks in KeystoneJS.
/**
* Email is a wrapper around the keystone Email object.
* @class Email
*
* @constructor
*
*/
module.exports = function Email(name, keystone, nunjucks) {
return new keystone.Email({
templateExt: 'html',
templateEngine: {
compile: function(html, paths) {
return function(locals) {
return nunjucks.renderString(html, locals);
};
}
},
templateName: name,
templateBasePath: keystone.get('emails'),
mandrill: {
track_opens: true,
track_clicks: true,
preserve_recipients: false,
inline_css: true
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment