[英]Using handlebars templates is there a way to render logic if looping over not the last item in an array?
使用 java handlebars 4.2.1 https://github.com/jknack/handlebars.java如果循環不是數組中的最后一項,是否有渲染邏輯的方法?
我知道我可以這樣做:
{{#myArray}}
{{#if @last}}
{{else}}
my rendered logic here
{{/if}}
{{/myArray}}
但我正在尋找只有一個塊的東西,類似於小胡子模板中的{{^-last}}
看起來可以使用 unless 助手來做到這一點:
{{#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.
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.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.