php-liquid icon indicating copy to clipboard operation
php-liquid copied to clipboard

for loop working incorrect with "in deep variable"

Open phambinh217 opened this issue 6 years ago • 2 comments

If I use for with "deep variable", the for loop working incorrect. Example

{% for product in collections[13].products %}
    <li>
        <span><a href="{{ product.url }}">{{ product.id }}: {{ product.title }}</a></span>
    </li>
{% endfor %}

My mean is loop all products in collections's index 13, but it loop collections, same case

{% for product in collections %}
    <li>
        <span><a href="{{ product.url }}">{{ product.id }}: {{ product.title }}</a></span>
    </li>
{% endfor %}

When I use bellow, it working well

{% assign products = collections[13].products %}
{% for product in products %}
    <li>
        <span><a href="{{ product.url }}">{{ product.id }}: {{ product.title }}</a></span>
    </li>
{% endfor %}

Please check! Sorry my bad english

phambinh217 avatar Mar 21 '18 02:03 phambinh217

No worries! Thanks for the report.

Please stick to {% assign ... %} for now. We'll see if we can fix this by the next release.

sanmai avatar Mar 21 '18 02:03 sanmai

Thank you so much

phambinh217 avatar Mar 21 '18 02:03 phambinh217