{{#each array}}
{{@index}}: {{this}}
{{/each}}
出現錯誤的洪水一個簡單的代碼。物件的{{@key}}
也是如此。爲什麼會發生?
{{#each array}}
{{@index}}: {{this}}
{{/each}}
出現錯誤的洪水一個簡單的代碼。物件的{{@key}}
也是如此。爲什麼會發生?
查看源代碼(在https://github.com/meteor/meteor/blob/master/packages/handlebars/parse.js):它看起來不像{{@ ..}}
表達式集與Meteor打包的Handlebars版本支持。
這對我來說絕對是一個挫折。在此期間,我做了一個車把助手來解析任何東西放入命名爲「關鍵」和「價值」的對象:也只是
<dl class="attributes">
{{#each key_value attributes}}
<dt>{{key}}</dt><dd>{{value}}</dd>
{{/each}}
</dl>
(I:
Handlebars.registerHelper('key_value', function(context, options) {
var result = [];
_.each(context, function(value, key, list){
result.push({key:key, value:value});
})
return result;
});
這與#each
運營商等一起使用發佈到相關Using @index in meteor #each iterator doesn't work)
謝謝,不知道。 – Euphe
鏈接無法使用。請更新:) –