Search code examples
javascripttemplatesdust.js

In dust.js can the inital value of $idx not be zero based?


If I am using the Index helper Is it possible to make the count start at 1 rather than 0. Both:

{@idx}{.}{/idx}

and

{$idx}

are zero based.

Does anyone know a way to do this?

It would be perfect if you could just do:

{$idx + 1}

but obviously that won't work.


Solution

  • I guess you can use math helper in combination with $idx:

    {@math key=$idx method="add" operand="1"/}