map
array | map: string
Creates an array of values from a specific property of the items in an array.
{%- assign product_titles = collection.products | map: 'title' -%}
{{ product_titles | join: ', ' }}
{%- assign product_titles = collection.products | map: 'title' -%}
{{ product_titles | join: ', ' }}
{
"collection": {
"products": [
{
"title": "Draught of Immortality"
},
{
"title": "Glacier ice"
},
{
"title": "Health potion"
},
{
"title": "Invisibility potion"
}
]
}
}
Output
Draught of Immortality, Glacier ice, Health potion, Invisibility potion
Was this page helpful?