我正在尝试遵循以下gulp插件的指南: https://www.npmjs.com/package/gulp-compile-handlebars
我正在使用的gulp功能在下面由“gulp pages”运行
<div class="megitsune">
<h2 title="Equippable item names are highlighted in blue.">Items</h2>
<div class="holder" title="Original value: 1" style="background: #DFEDF7">
Bow <input type="text" value="1" data-obj="5" data-type="item" class="objchange">
</div>
<div class="holder" title="Original value: 1">
Character <input type="text" value="1" data-obj="2" data-type="item" class="objchange">
</div>
<div class="holder" title="Original value: 0">
Food <input type="text" value="0" data-obj="7" data-type="item" class="objchange">
</div>
<div class="holder" title="Original value: 3" style="background: #DFEDF7">
Hungry <input type="text" value="3" data-obj="22" data-type="item" class="objchange">
</div>
<div class="holder" title="Original value: 0" style="background: #DFEDF7">
Injury: Back <input type="text" value="0" data-obj="19" data-type="item" class="objchange">
</div>
<div class="holder" title="Original value: 0" style="background: #DFEDF7">
Injury: Broken Arm <input type="text" value="0" data-obj="16" data-type="item" class="objchange">
</div>
<div class="holder" title="Original value: 0" style="background: #DFEDF7">
Injury: Broken Leg <input type="text" value="0" data-obj="17" data-type="item" class="objchange">
</div>
<div class="holder" title="Original value: 0" style="background: #DFEDF7">
Injury: Eye <input type="text" value="0" data-obj="18" data-type="item" class="objchange">
</div>
<div class="holder" title="Original value: 0" style="background: #DFEDF7">
Iron Axe <input type="text" value="0" data-obj="4" data-type="item" class="objchange">
</div>
<div class="holder" title="Original value: 0" style="background: #DFEDF7">
Iron Sword <input type="text" value="0" data-obj="3" data-type="item" class="objchange">
</div>
<div class="holder" title="Original value: 5">
Meat <input type="text" value="5" data-obj="9" data-type="item" class="objchange">
</div>
<div class="holder" title="Original value: 2">
temp <input type="text" value="2" data-obj="10" data-type="item" class="objchange">
</div>
<div class="holder" title="Original value: 0">
temp2 <input type="text" value="0" data-obj="21" data-type="item" class="objchange">
</div>
<div class="holder" title="Original value: 8">
times_gathered <input type="text" value="8" data-obj="15" data-type="item" class="objchange">
</div>
<div class="holder" title="Original value: 0">
times_hunted <input type="text" value="0" data-obj="14" data-type="item" class="objchange">
</div>
<div class="holder" title="Original value: 0">
time_day <input type="text" value="0" data-obj="11" data-type="item" class="objchange">
</div>
<div class="holder" title="Original value: 0">
time_night <input type="text" value="0" data-obj="12" data-type="item" class="objchange">
</div>
<div class="holder" title="Original value: 0">
Wet Wood <input type="text" value="0" data-obj="8" data-type="item" class="objchange">
</div>
<div class="holder" title="Original value: 1">
Wood <input type="text" value="1" data-obj="6" data-type="item" class="objchange">
</div>
<div class="holder" title="Original value: 0">
z_youwin <input type="text" value="0" data-obj="20" data-type="item" class="objchange">
</div>
</div>
});
我有一个像这样加载部分的页面:
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/'));
我收到以下错误:
{{> _common/header/header}}
现在已经差不多6个小时了,我似乎无法在网上的任何地方找到解决方案,所以在我诚实地放弃之前,这是我的最后手段。
答案 0 :(得分:3)
你必须替换:
.pipe(handlebars(options))
由:
.pipe(handlebars(null, options))