From ebf7f9232fb286966720104d28cca62f964cd071 Mon Sep 17 00:00:00 2001 From: Adam Hollett Date: Thu, 22 Jun 2017 11:04:23 -0400 Subject: [PATCH] Add documentation for concat filter --- filters/concat.md | 58 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 filters/concat.md 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 +```