conditional on last item in array using handlebars.js template

前端 未结 6 2026
我在风中等你
我在风中等你 2020-12-04 15:17

I am leveraging handlebars.js for my templating engine and am looking to make a conditional segment display only if it is the last item in array contained in the templates c

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-04 16:02

    Since Handlebars 1.1.0, first and last has become native to the each helper. See ticket #483.

    The usage is like Eberanov's helper class:

    {{#each foo}}
        
    {{@key}} - {{@index}}
    {{/each}}

提交回复
热议问题