使用 java 车把 4.2.1 https://github.com/jknack/handlebars.java 如果循环不是数组中的最后一项,有没有办法呈现逻辑?
我知道我可以这样做:
{{#myArray}}
{{#if @last}}
{{else}}
my rendered logic here
{{/if}}
{{/myArray}}
但我正在寻找只有一个块的东西,类似于
{{^-last}}
来自 mustache 模板
使用 java 车把 4.2.1 https://github.com/jknack/handlebars.java 如果循环不是数组中的最后一项,有没有办法呈现逻辑?
我知道我可以这样做:
{{#myArray}}
{{#if @last}}
{{else}}
my rendered logic here
{{/if}}
{{/myArray}}
但我正在寻找只有一个块的东西,类似于
{{^-last}}
来自 mustache 模板
看起来可以使用除非助手来做到这一点:
{{#myArray}}
{{#unless @last}}
my rendered logic here
{{/unless}}
{{/myArray}}
根据他们的文档 You can use the unless helper as the inverse of the if helper. Its block will be rendered if the expression returns a falsy value.