Difficulties with gulp-front-matter
leocreatini opened this issue · comments
Hi Shannon, I know this is a bit of a tangent from gulp-hb, however, I've been struggling with incorporating frontMatter and layouts for a day now and could use your expertise.
I can get the *.hbs to compile with their data, however there's a 'layout' property in the front-matter that should wrap the generated html with the layout template.
gulp.task('html', function() {
var hbOptions = {
data: paths.dir.data,
helpers: [
paths.dir.helpers,
paths.dir.helplayouts
],
partials: [
paths.files.partials,
paths.files.layouts
],
file: true
}; //hbOptions
var fmOptions = {
remove: true
}; //fmOptions
return gulp
.src(paths.files.pages)
.pipe( fm(fmOptions) )
.pipe( hb(hbOptions) )
.pipe( rename( {extname: '.html'} ))
.pipe( gulp.dest(paths.dir.test + paths.dir.dist) );
}); //html
This is all a bit new to me, I'm more used to Angular -- any help would be greatly appreciated!
@leocreatini Did you find a solution? The front-matter module doesn't automatically handle layouts. Looks like you might be using handlebars-layouts. If so, you could do this:
But I generally prefer to skip using frontMatter for that and just use the layout name directly.
Thanks for the reply. Sort of found a solution, I am in the process of hacking together a gulp assemble into its own plugin. The hb package has been wonderful for the page, yet piping the layout afterwards via assemble's manner with the {{> body }}
syntax was a hassle.
Ended up using front-matter, finding the page's layout, doing regex to replace the {{> body }}
with the content.body
, compiling the layout, then buffering it back out.
It was an eventful weekend :)