如果循环遍历的不是数组中的最后一项,那么使用java handlebars 4.2.1 https://github.com/jknack/handlebars.java有没有一种呈现逻辑的方法?
我知道我可以做到:
{{#myArray}}
{{#if @last}}
{{else}}
my rendered logic here
{{/if}}
{{/myArray}}但我正在寻找只有一个块的东西,类似于胡子模板中的{{^-last}}
发布于 2021-10-03 18:42:24
看起来人们可以使用除非帮助器来做这件事:
{{#myArray}}
{{#unless @last}}
my rendered logic here
{{/unless}}
{{/myArray}}每个their docs 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.
https://stackoverflow.com/questions/69427822
复制相似问题