Skip to content

Commit

Permalink
glob support for helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
jonschlinkert committed Jul 27, 2015
1 parent 65fb958 commit f315aaa
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion lib/helpers/methods.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
'use strict';

var path = require('path');
var lazy = require('lazy-cache')(require);
var helpers = lazy('helper-cache');
var visit = lazy('object-visit');
var isGlob = require('is-glob');
var globby = require('lazy-globby');
var utils = require('../utils');


Expand Down Expand Up @@ -75,9 +78,21 @@ module.exports = function (app) {
return this;
}
if (Array.isArray(helpers)) {
utils.mapVisit(this, 'helper', helpers);
this.mapVisit('helper', helpers);
return this;
}

if (isGlob(helpers)) {
this.loader('helpers-glob', ['base-glob'], function (files) {
return files.map(function (fp) {
return require(path.resolve(fp));
})
})
var res = this.compose('helpers-glob')(helpers, options);
this.mapVisit('helper', res);
return this;
}

if (typeof helpers === 'string') {
console.log('loading helpers from a string is not implemented yet.');
}
Expand Down

0 comments on commit f315aaa

Please # to comment.