bkiers / Liqp

An ANTLR based 'Liquid Template' parser and rendering engine.
MIT License
165 stars 94 forks source link

Invalid scope for cycle tag #183

Closed msangel closed 3 years ago

msangel commented 3 years ago

tldr: In the liquid this template: "{% cycle 1,2,3 %}{% assign list = \"1\" | split: \",\" %}{% for n in list %}{% cycle 1,2,3 %}{% endfor %}{% cycle 1,2,3 %}" will give this output: "123" while this library gives "121" (incorrect)

Details: In the liquid the track of the current cycle state is tracked in context.registers[:cycle] object, which itself is a hash-object, where the key is string representation of given cycle arguments, like "[1,2,3]", and the value is last iteration position, and this collection is global. Same as https://github.com/bkiers/Liqp/issues/181 this is a part of the fix for https://github.com/bkiers/Liqp/issues/179