Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the total items in an array(array length) in dust.js

Tags:

dust.js

I can't seem to figure out(I'm pretty sure that I'm over thinking or not thinking here) a way to get the length of an array in the following example. Can anyone please help me, or direct me to a good tutorial. https://github.com/linkedin/dustjs/wiki/Dust-Tutorial has mentioned the {@size} helper but does not have any examples.

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

Thank you in advance.

like image 604
Wasula Kankanamge Avatar asked Dec 27 '22 07:12

Wasula Kankanamge


1 Answers

Yep, I was clearly overlooking. I was not including ( require('dustjs-helpers'); ) in order to use

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

Hope this will help others out as well.

like image 118
Wasula Kankanamge Avatar answered Mar 23 '23 03:03

Wasula Kankanamge