0
我有一个帮手,通过贾森数据循环直到给定的值,并将数据发回模板。我也想显示数据存在的位置(索引),在那里任何方式,我可以返回索引值与数据?handlebars返回索引连同数据
Handlebars.registerHelper('print_range', function(items,count,options)
{
var out = "";
for(var i=0, l=items.length; i<count; i++)
{
out = out + options.fn(items[i]);
}
return out;
});
<script id="template" type="text/x-handlebars-template">
{{#print_range options "2"}}
<h1>index</h1> // this index should correspond to i in the helper function
<h2>{{optionID}}{{nextID}}</h2>
{{/print_range}}
</script>
在此先感谢。