Search code examples
jekyllliquid

How can I reset an increment?


In some template I'm iterating some data using a for loop which is part of some other parent for loop.

Using some conditions, I need to increment a counter for each iteration of the inner for loop, and reset it whenever the template goes to the next outer for loop iteration.

I'm using {% increment someVar %}, but I can't figure out how to reset someVar to 0.

Is this ever possible?


Solution

  • Use {% assign someVar = 0 %}, increment with {% assign someVar = someVar | plus: 1 %}.