Skip to content

Commit

Permalink
Fix the batch problem ( has no method slice )
Browse files Browse the repository at this point in the history
You can't pass to ejs.render() a function so if html is a function ( probably in batch mode ) then we set the html to that.html before calling ejs.render.
  • Loading branch information
vekexasia committed Nov 1, 2012
1 parent 5b2847d commit 520f897
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/main.js
Expand Up @@ -51,14 +51,18 @@ var EmailTemplate = function(templateDirectory, defaults, done) {
bufferType = that.bufferType
}

if (typeof html === 'function') {
callback = html;
html = that.html;
}
if (!html) html = that.html
if (!text) text = that.text
if (!stylesheet) stylesheet = that.stylesheet
locals = _.defaults(locals, (typeof defaults === 'object') ? defaults : {});
html = ejs.render(html, locals);
text = (text) ? ejs.render(text, locals) : '';
if (stylesheet) html = juice(html, stylesheet);
if (typeof html === 'function') callback = html;


// return a compressed buffer
if (isBuffer) {
Expand Down

0 comments on commit 520f897

Please sign in to comment.