首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >吞咽-编译-不找到部分

吞咽-编译-不找到部分
EN

Stack Overflow用户
提问于 2016-12-19 22:07:01
回答 1查看 1.1K关注 0票数 0

我试图遵循以下gulp插件的指导原则:https://www.npmjs.com/package/gulp-compile-handlebars

下面是我使用的gulp函数,它由"gulp页面“运行。

代码语言:javascript
复制
gulp.task('pages', function () {

var options = {
    ignorePartials: true, //ignores the unknown footer2 partial in the handlebars template, defaults to false 
    partials : {
        footer : '<footer>the end</footer>'
    },
    batch : ['_hbs'],
    helpers : {
        capitals : function(str){
            return str.toUpperCase();
        }
    }
}
return gulp.src('_hbs/*.hbs')
    .pipe(handlebars(options))
    .pipe(rename(function (path) {
          path.extname = ".html"
        })
     )

    // Flatten structure
    //.pipe(flatten())

    // pretify html structure
   // .pipe(prettify({
   //   indent_size: 4
   // }))

    .pipe(gulp.dest('_hbs/'));

});

我有一个页面正在加载一个部分,如下所示:

代码语言:javascript
复制
{{> _common/header/header}}

我收到以下错误:

代码语言:javascript
复制
events.js:160
      throw er; // Unhandled 'error' event
      ^
Error: **The partial _common/header/header could not be found**
    at Object.invokePartial (C:\wamp\www\developer\HTML_seed\node_module
s\handlebars\dist\cjs\handlebars\runtime.js:271:11)
    at Object.invokePartialWrapper [as invokePartial] (C:\wamp\www\devel
oper\HTML_seed\node_modules\handlebars\dist\cjs\handlebars\runtime.js:68:39)
    at Object.eval (eval at createFunctionContext (C:\wamp\www\developer
\HTML_seed\node_modules\handlebars\dist\cjs\handlebars\compiler\javascript-compi
ler.js:254:23), <anonymous>:5:31)
    at main (C:\wamp\www\developer\HTML_seed\node_modules\handlebars\dis
t\cjs\handlebars\runtime.js:173:32)
    at ret (C:\wamp\www\developer\HTML_seed\node_modules\handlebars\dist
\cjs\handlebars\runtime.js:176:12)
    at ret (C:\wamp\www\developer\HTML_seed\node_modules\handlebars\dist
\cjs\handlebars\compiler\compiler.js:525:21)
    at DestroyableTransform._transform (C:\wamp\www\developer\HTML_seed\
node_modules\gulp-compile-handlebars\index.js:131:31)
    at DestroyableTransform.Transform._read (C:\wamp\www\developer\HTML_
seed\node_modules\gulp-compile-handlebars\node_modules\readable-stream\lib\_stre
am_transform.js:184:10)
    at DestroyableTransform.Transform._write (C:\wamp\www\developer\HTML
_seed\node_modules\gulp-compile-handlebars\node_modules\readable-stream\lib\_str
eam_transform.js:172:12)
    at doWrite (C:\wamp\www\developer\HTML_seed\node_modules\gulp-compil
e-handlebars\node_modules\readable-stream\lib\_stream_writable.js:237:10)

现在已经快6个小时了,我似乎在网上任何地方都找不到解决办法,所以在我诚实放弃之前,这是我最后的选择。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-12-20 01:17:35

你必须替换:

代码语言:javascript
复制
    .pipe(handlebars(options))

出自:

代码语言:javascript
复制
    .pipe(handlebars(null, options))
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41231790

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档