Permalink
Browse files

Update lib/main.js

changed instanceof Function to typeof html === 'function' to ensure compatibility with vm.
  • Loading branch information...
1 parent bb43563 commit 3a64de4979535b34f5619172de0455c171f90ae3 Patrick Heneise committed Aug 2, 2012
Showing with 4 additions and 5 deletions.
  1. +4 −5 lib/main.js
View
@@ -1,4 +1,3 @@
-
// node-email-templates
// Copyright (c) 2012 Nick Baugh <niftylettuce@gmail.com>
// MIT Licensed
@@ -24,7 +23,7 @@ var EmailTemplate = function(templateDirectory, done) {
this.text = '';
this.stylesheet = '';
this.render = function(locals, html, text, stylesheet, callback) {
- if (html instanceof Function) {
+ if (typeof html === 'function') {
callback = html;
html = that.html;
text = that.text;
@@ -33,7 +32,7 @@ var EmailTemplate = function(templateDirectory, done) {
html = ejs.render(html, locals);
text = (text) ? ejs.render(text, locals) : '';
if (stylesheet) html = juice(html, stylesheet);
- if (html instanceof Function) callback = html;
+ if (typeof html === 'function') callback = html;
return callback(null, html, text);
};
@@ -54,10 +53,10 @@ var EmailTemplate = function(templateDirectory, done) {
// Fallback if user doesn't pass all the args
var batchEmail = false;
- if (typeof locals !== 'undefined' && locals instanceof Function) {
+ if (typeof locals !== 'undefined' && typeof locals === 'function') {
callback = locals;
locals = {};
- } else if (typeof callback !== 'undefined' && callback instanceof Function) {
+ } else if (typeof callback !== 'undefined' && typeof callback === 'function') {
if (typeof locals === 'undefined' || !locals instanceof Object) {
locals = {};
} else if (locals === true) {

0 comments on commit 3a64de4

Please sign in to comment.