0
我試圖產生一種選擇一套在那裏我可以選擇所選擇的選項,但我不能夠訪問到timeSpent
當我巢助手就像上面的例子:如何獲取Handlebars Helper範圍內的父數據?
這是我如何將數據發送到我把手模板:
{
feed : {
foodMinutes : 90,
timeSpent : 72
}
}
這是我生成我選擇選項,我覺得有像../timeSpent
一個辦法讓母公司的數據,但它不工作:
<select>
{{#count feed.foodMinutes 1 0}}
{{#equal ../timeSpent this}}
<option value="{{this}}" selected>{{this}} minuti</option>
{{else}}
<option value="{{this}}">{{this}} minuti</option>
{{/equal}}
{{/count}}
</select>
這些都是我的幫手:
Handlebars.registerHelper("count", function(count, step, start, block) {
var accum, steps, startFrom;
accum = "";
steps = step || 1;
startFrom = start || 0;
for(var i = startFrom; i < count; i += steps) {
accum += block.fn(i);
}
return accum;
});
Handlebars.registerHelper("equal", function(lvalue, rvalue, options) {
if (arguments.length < 3) {
throw new Error("Handlebars Helper equal needs 2 parameters");
}
if (lvalue != rvalue) {
return options.inverse(this);
} else {
return options.fn(this);
}
});
那麼我怎樣才能得到Handlebars Helper範圍內的父數據?