Ad

How Do I Iterate Over Two Arrays In Parallel With Liquid

- 1 answer

I have 2 arrays "a_group" [a,a,a,a] and "b_group" [b,b,b]
I'm iterating with the following loop:

 {% for  a in a_group and b in b_group %}
         <p> {{ a }}: {{b}} </p>  
{% endfor %}

expected result:
a: b
a: b
a: b
a: No data available

what i actually get:
a: No data available
a: No data available
a: No data available
a: No data available

Ad

Answer

If you need both an A element and a B element at the same time, you can always use indexes to cherry-pick them off, or nested loops. There is no concept of parallel processing that will help you otherwise.

Ad
source: stackoverflow.com
Ad