Created
December 22, 2013 16:19
-
-
Save bennett000/8084826 to your computer and use it in GitHub Desktop.
EJS Filter Hack on node-email-templates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// from main.js | |
// this is just a hack :) | |
// # Email Template | |
var EmailTemplate = function(templateDirectory, defaults, filters, done) { | |
if (typeof defaults === 'function') done = defaults; | |
// move the done function "over" if the filters arent' being used | |
if (typeof filters === 'function') done = filters; | |
// iterate over the filters, skip non functions | |
// add the filters to ejs instance | |
// | |
// I also did a hack which would not overwrite existing filters | |
_.each(filters, function (fn, filter) { | |
if (typeof fn !== 'function') { return; } | |
ejs.filters[filter] = fn; | |
}); | |
// body of the node-email-templates | |
// untouched | |
}); | |
// modified export statement to include filters | |
module.exports = function(templateDirectory, defaults, filters, done) { | |
return new EmailTemplate(templateDirectory, defaults, filters, done); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment