handlebars.js:从1. for-each获取@key?

时间:2013-12-02 21:52:57

标签: javascript handlebars.js

对标题感到抱歉,不知道还有什么可以称之为:(

我是handlebars.js的新手,我试图这样做:

{{#each .}}
    @key 
    {{#each .}}
    @key from the first "each"     <<<< this is the problem   
    @value
    {{/each}}     
{{/each}}

如何从第一个“每个”中获取@key以用于我的2.“每个”?

解决方案

{{#each .}}
{{type @key}}
    @key 
        {{#each .}}
        {{ ../@key }}    
        @value
    {{/each}}     
{{/each}}

Handlebars.registerHelper('type', function(value){
this.key = value;
});

0 个答案:

没有答案