I'm currently using Gulp as the build tool for a project. One of the Gulp tasks uses Assemble to assemble the Handlebars pages/layouts into HTML:
var assemble = require('assemble')();
gulp.task('assemble', ['clean'], function () {
assemble.partials('./partials/**/*.hbs');
assemble.layouts('./layouts/**/*.hbs');
assemble.pages('./pages/**/*.hbs');
loadHelpers(); // Calls assemble.helpers(...) on some Handlebars helpers
var data = require('./hbs_context.json');
assemble.data(data);
assemble.data({root: process.cwd()});
return assemble.toStream('managements')
.pipe(assemble.renderFile())
.pipe(plugins.extname()) // Converts .hbs to .html
.pipe(gulp.dest('.tmp/'));
});
I've come upon a part of my project which requires multiple pages created from an array of data, where each object of the array would be a context for a separate page.
This same problem has been brought up and answered many times:
How can I generate multiple pages from a JSON file with Assemble
Assemble: How can I generate pages from json/yaml?
grunt assemble multiple files from one datafile
https://github.com/assemble/assemble/issues/236
https://github.com/assemble/assemble/issues/184
https://github.com/assemble/assemble/pull/234
However, all the solutions provided use Grunt options, and I can't figure out how to do the same thing in Gulp. So, is there an equivalent way to do this in Gulp?