How to get the total number of elements in an array (array length) in dust.js

I can't figure it out (I'm sure I was thinking or not thinking here) to get the length of the array in the following example. Can someone help me or direct me to a good tutorial. https://github.com/linkedin/dustjs/wiki/Dust-Tutorial mentioned the {@size} helper, but has no examples.

<ul total-tems={#items.length/}> {#items} <li class="item-{$idx}">{.title}</li> {/items} </ul> 

Thanks in advance.

+4
source share
2 answers

Yes, I obviously didn’t notice. I did not turn on (require ("assistant vacuum cleaners");) to use

 <ul total-tems="{@size key=items /}"> 

Hope this helps others too.

+10
source

I don't know if this is a new dustjs feature, but now you can just use {items.length} to access the length of the array without the need for helpers.

0
source

Source: https://habr.com/ru/post/1468764/


All Articles