diff --git a/index.js b/index.js index 35de2f5..bed943e 100644 --- a/index.js +++ b/index.js @@ -1,10 +1,10 @@ var gutil = require('gulp-util'); var through = require('through2'); -var Handlebars = require('handlebars'); var Promise = require('bluebird'); var _ = require('lodash'); var Path = require('path'); var writable = require('./lib/writable'); +var Handlebars = null; /** * Duck-typing to allow different promise implementations to work. @@ -59,7 +59,7 @@ function getPromises(obj, fn) { } else if (isPromise(obj)) { obj.then(function (result) { getPromises(result, fn); - }) + }); } return []; } @@ -68,8 +68,8 @@ module.exports = function (data, options) { var dataDependencies; options = options || {}; var dependencies = []; + Handlebars = Handlebars || require('handlebars'); //Go through a partials object - if (data) { if (isPromise(data)) { dataDependencies = data.then(function (result) { @@ -126,4 +126,12 @@ module.exports = function (data, options) { }); }; -module.exports.Handlebars = Handlebars; + +module.exports.using = function () { + Handlebars = Handlebars || require('handlebars'); + return Handlebars; +}; + +module.exports.use = function (customHandlebars) { + Handlebars = customHandlebars; +};