Files
liquid/_filters/concat.md
2019-07-28 16:27:13 -04:00

1.1 KiB

title, description
title description
concat Liquid filter that concatenates arrays.

Concatenates (joins together) multiple arrays. The resulting array contains all the items from the input arrays.

Input

{% raw %} ```liquid {% assign fruits = "apples, oranges, peaches" | split: ", " %} {% assign vegetables = "carrots, turnips, potatoes" | split: ", " %}

{% assign everything = fruits | concat: vegetables %}

{% for item in everything %}

  • {{ item }} {% endfor %}
{% endraw %}

<p class="code-label">Output</p>
```text
- apples
- oranges
- peaches
- carrots
- turnips
- potatoes

You can string together concat filters to join more than two arrays:

Input

{% raw %} ```liquid {% assign furniture = "chairs, tables, shelves" | split: ", " %}

{% assign everything = fruits | concat: vegetables | concat: furniture %}

{% for item in everything %}

  • {{ item }} {% endfor %}
{% endraw %}

<p class="code-label">Output</p>
```text
- apples
- oranges
- peaches
- carrots
- turnips
- potatoes
- chairs
- tables
- shelves