Closed spacedawwwg closed 9 years ago
Released as v2.4.3.
var hb = require('gulp-hb');
console.log(hb.handlebars);
While I was happy to make this change, I usually defer complicated data collection and helper/partial registration to separate files to keep my gulpfiles clean:
// gulpfile.js
...
.pipe(hb({
data: './data/**/*.js',
helpers: './helpers/**/*.js',
partials: './partials/**/*.js',
})
...
// data/site.js
var navTree = {};
// generate tree
module.exports = {
navTree: navTree
};
// helpers/advanced.js
module.exports.register = function (handlebars) {
// complicated stuff here
};
That sort of thing.
I get you.
I think that is how I will register custom helpers (e.g {{#either}} ).
Though, for helper such as your 'handlebars-layouts', I like to manage them through devDependencies.
Thanks again, @shannonmoeller - You have been a saviour this week!
Totally. I'm personally okay with globbing into node_modules
, but if I change my mind on that, I'd probably do this:
// helpers/vendor.js
var layouts = require('handlebars-layouts');
var markdown = require('helper-markdown');
module.exports.register = function (handlebars) {
handlebars.registerHelper(layouts(handlebars));
handlebars.registerHelper('markdown', markdown);
};
Glad that gulp-hb
has been useful. I really like the direction they're taking Assemble, but they've got some kinks to work out. :)
Would it be possible to expose Handlebars gulp-hb is using? Making it possible to register helpers .etc without the need to pass a full path the 'node_module' directory
e.g