diff --git a/filters/concat.md b/filters/concat.md new file mode 100644 index 0000000..914e388 --- /dev/null +++ b/filters/concat.md @@ -0,0 +1,58 @@ +--- +title: concat +description: 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 %} + +

Output

+```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 %} + +

Output

+```text +- apples +- oranges +- peaches +- carrots +- turnips +- potatoes +- chairs +- tables +- shelves +```