bkiers / Liqp

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

Includes within for loop is missing variables #179

Closed Katsute closed 3 years ago

Katsute commented 3 years ago

When using includes within a for loop only the iterator variable can be accessed by the includes, it doesn't return a value for both global assigned variables and variables assigned within the loop.

HTML file

{% assign list = "1,2,3,4" | split: "," %}
{% for n in list %}
    {% assign inner = n %}
    {% include include.liquid %}
{% endfor %}

Liquid includes file

list: {{ list }} <br>
inner: {{ inner }} <br>
n: {{ n }}
<hr>

Response

list:
inner:
n: 1
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
list:
inner:
n: 2
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
list:
inner:
n: 3
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
list:
inner:
n: 4
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
msangel commented 3 years ago

Working in this.