Files
liquid/_filters/concat.md
2021-04-28 13:43:02 -04:00

1.1 KiB

title, description, version-badge
title description version-badge
concat Liquid filter that concatenates arrays. 4.0.0

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

Input

```liquid {%- raw -%} {% 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 multiple concat filters to join more than two arrays.

Input

```liquid {%- raw -%} {% 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