Shopify / Liquid specific loop index within loop
<p>In Shopify I am trying to cycle through some metafields that contain feature titles. Then I need to cycle through some other metafields and get the feature description based on the current loop index.</p>

<p>This code works just fine for me, but it is very inelegant and I'm sure there is a much better way to achieve the same result!</p>

<pre><code>{% for field in product.metafields.feature_title %}
    &lt;h4&gt;{{ field | last }}&lt;/h4&gt;
    {% assign i = forloop.index %}
    {% if forloop.index == 1 %}
         &lt;p&gt;{{ product.metafields.feature_description.001 }}&lt;/p&gt;
    {% endif %}
    {% if forloop.index == 2 %}
         &lt;p&gt;{{ product.metafields.feature_description.002 }}&lt;/p&gt;
    {% endif %}
    {% if forloop.index == 3 %}
         &lt;p&gt;{{ product.metafields.feature_description.003 }}&lt;/p&gt;
    {% endif %}
    {% if forloop.index == 4 %}
         &lt;p&gt;{{ product.metafields.feature_description.004 }}&lt;/p&gt;
    {% endif %}
    {% if forloop.index == 5 %}
    &lt;p&gt;{{ product.metafields.feature_description.005 }}&lt;/p&gt;
    {% endif %}
{% endfor %}
</code></pre>

<p>Additionally there is a flaw that this is limited to 5, or whoever many if statements creates.</p>

<p>Cheers,</p>

<p>DB</p>