map

Creates an array of values by extracting the values of a named property from another object

Input
  • foo = { "food": { "fruit": [ "apple", "banana" ] } }
    {% assign all_fruits = foo.food | map: 'fruit' %}
    {% for item in all_fruits %}{{ item }}{% endfor %}
Output
  • apple, banana