I am new to the gulp frameworks. I have been working on a small gulp script, which will pipe a Markdown file to a JSON string, then use a Jade template to render the final HTML. I am using gulp-wrap
to pass the data into my jade template
// md to jade blog
gulp.task('blog', () => {
gulp.src(path.join(dirs.source, dirs.blogs, entries.md))
.pipe(md(marked))
.pipe(plumber())
.pipe(wrap(function(data) {
// read correct jade template from disk
let template = path.join(dirs.source, dirs.layouts, data.contents.template)
// template location is at 'src/_layouts/base-blog.jade'
return fs.readFileSync(template).toString();
}, {
}, {
engine: 'jade'
}))
.pipe(rename({extname:'.html'}))
.pipe(gulp.dest(dest));
});
}
I keep getting the following error when I run it:
Message:
Jade:11
9| //- var pageTitle = config.pageTitle || ''
10|
> 11| include ../_modules/project-list/project-list
12| include ../_modules/about/about
13|
14| doctype html
the "filename" option is required to use "include" with "relative" paths
Details:
path: undefined
Does anyone have an idea of how to solve this problem?
The error message is pretty clear here:
the "filename" option is required to use "include" with "relative" paths
So:
either find a way to pass the "filename" option to your Jade/Pug command, by using -p
> pug --help
[...]
-p, --path <path> filename used to resolve includes
or make your file paths absolute