需要 "filename" 选项才能将 "include" 与 "relative" 路径一起使用
The "filename" option is required to use "include" with "relative" paths
我是 gulp 框架的新手。我一直在研究一个小的 gulp 脚本,它将 Markdown 文件通过管道传输到 JSON 字符串,然后使用 Jade 模板渲染最终的 HTML。我正在使用 gulp-wrap
将数据传递到我的 jade 模板中
// 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));
});
}
当我 运行 它时,我不断收到以下错误:
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
有没有人知道如何解决这个问题?
这里的错误信息很清楚:
the "filename" option is required to use "include" with "relative" paths
所以:
要么想办法将 "filename" 选项传递给 Jade/Pug 命令,方法是使用 -p
> pug --help
[...]
-p, --path <path> filename used to resolve includes
或者让你的文件路径成为绝对路径
我是 gulp 框架的新手。我一直在研究一个小的 gulp 脚本,它将 Markdown 文件通过管道传输到 JSON 字符串,然后使用 Jade 模板渲染最终的 HTML。我正在使用 gulp-wrap
将数据传递到我的 jade 模板中
// 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));
});
}
当我 运行 它时,我不断收到以下错误:
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
有没有人知道如何解决这个问题?
这里的错误信息很清楚:
the "filename" option is required to use "include" with "relative" paths
所以:
要么想办法将 "filename" 选项传递给 Jade/Pug 命令,方法是使用
-p
> pug --help [...] -p, --path <path> filename used to resolve includes
或者让你的文件路径成为绝对路径