Click here to Skip to main content
15,886,833 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have {{#eac list}}{{/each}} loop inside view. Now i want to decalre a varaible suppose x inside this loop and increment this variable with every iteration of the loop. i am using nodejs, exxpressjs and handlebars as template engine

What I have tried:

have no idea how to write it within loop inside hbs view
Posted
Comments
Richard Deeming 10-Aug-20 5:19am    
Handlebars already provides the @index variable which provides the zero-based index of the loop iteration step:
@data variables | Handlebars[^]
Sam_k_khan 10-Aug-20 6:09am    
but @index and @key start from 0. i need it from 1, how do perform increment or decrement operations within view?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900