Counter for handlebars #each

后端 未结 8 950
小鲜肉
小鲜肉 2021-02-04 02:29

In Handlebars, say i have a collection of names how can i do

{{#each names}}
{{position}}
{{name}}
{{/each}}

where {{position}} is

相关标签:
8条回答
  • 2021-02-04 02:58

    you can get value just from index inside the list.

    {{#each list}}
        @index
    {{/each}}
    
    0 讨论(0)
  • 2021-02-04 03:00

    only you have to use {{@index}}

    example:

    {{#.}}
    <li class="order{{@index}}"> counter: {{@index}}</li>
    {{/.}}
    
    0 讨论(0)
提交回复
热议问题