Cycle tag inside Render snippet

asquaredagency
New Member
3 0 0

I am looping through products and I need the cycle tag based on loop.

{% for product in collection.products %}
   {% render 'product-grid-item', product: product %}
{% endfor %}

Inside the "product-grid-item", I have:

{% assign class_1 = 'small-6 medium-4' %}
{% assign class_2 = 'small-6 medium-3' %}
{% capture grid_item_width %} {% cycle class_1, class_1, class_1, class_2, class_2, class_2, class_2 %} {% endcapture %}

The cycle is not working, because it is not directly inside the "for loop". Any idea how to get this working?

I am aware of alternatives, I am just trying to make "cycle" work inside a render tag.

This used to work with "include".

0 Likes