concat
array | concat: array
Concatenates (combines) two arrays.
Note
The concat
filter won't filter out duplicates. If you want to remove duplicates, then you need to use the
uniq
filter.
{%- assign types_and_vendors = collection.all_types | concat: collection.all_vendors -%}
Types and vendors:
{% for item in types_and_vendors -%}
{%- if item != blank -%}
- {{ item }}
{%- endif -%}
{%- endfor %}
{%- assign types_and_vendors = collection.all_types | concat: collection.all_vendors -%}
Types and vendors:
{% for item in types_and_vendors -%}
{%- if item != blank -%}
- {{ item }}
{%- endif -%}
{%- endfor %}
{
"collection": {
"all_types": [
"",
"Animals & Pet Supplies",
"Baking Flavors & Extracts",
"Container",
"Cooking & Baking Ingredients",
"Dried Flowers",
"Fruits & Vegetables",
"Gift Cards",
"Health",
"Health & Beauty",
"Invisibility",
"Love",
"Music & Sound Recordings",
"Seasonings & Spices",
"Water"
],
"all_vendors": [
"Clover's Apothecary",
"Polina's Potent Potions",
"Ted's Apothecary Supply"
]
}
}
Output
Types and vendors:
- Animals & Pet Supplies
- Baking Flavors & Extracts
- Container
- Cooking & Baking Ingredients
- Dried Flowers
- Fruits & Vegetables
- Gift Cards
- Health
- Health & Beauty
- Invisibility
- Love
- Music & Sound Recordings
- Seasonings & Spices
- Water
- Clover's Apothecary
- Polina's Potent Potions
- Ted's Apothecary Supply
Was this page helpful?