Skip to content

Commit ebf7f92

Browse files
author
Adam Hollett
committed
Add documentation for concat filter
1 parent 1db4219 commit ebf7f92

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

filters/concat.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
title: concat
3+
description: Liquid filter that concatenates arrays.
4+
---
5+
6+
Concatenates (joins together) multiple arrays. The resulting array contains all the items from the input arrays.
7+
8+
<p class="code-label">Input</p>
9+
{% raw %}
10+
```liquid
11+
{% assign fruits = "apples, oranges, peaches" | split: ", " %}
12+
{% assign vegetables = "carrots, turnips, potatoes" | split: ", " %}
13+
14+
{% assign everything = fruits | concat: vegetables %}
15+
16+
{% for item in everything %}
17+
- {{ item }}
18+
{% endfor %}
19+
```
20+
{% endraw %}
21+
22+
<p class="code-label">Output</p>
23+
```text
24+
- apples
25+
- oranges
26+
- peaches
27+
- carrots
28+
- turnips
29+
- potatoes
30+
```
31+
32+
You can string together `concat` filters to join more than two arrays:
33+
34+
<p class="code-label">Input</p>
35+
{% raw %}
36+
```liquid
37+
{% assign furniture = "chairs, tables, shelves" | split: ", " %}
38+
39+
{% assign everything = fruits | concat: vegetables | concat: furniture %}
40+
41+
{% for item in everything %}
42+
- {{ item }}
43+
{% endfor %}
44+
```
45+
{% endraw %}
46+
47+
<p class="code-label">Output</p>
48+
```text
49+
- apples
50+
- oranges
51+
- peaches
52+
- carrots
53+
- turnips
54+
- potatoes
55+
- chairs
56+
- tables
57+
- shelves
58+
```

0 commit comments

Comments
 (0)