concat
将多个数组连接在一起。产生的数组包含了输入数组中的所有项目。
输入
{% assign fruits = "apples, oranges, peaches" | split: ", " %}
{% assign vegetables = "carrots, turnips, potatoes" | split: ", " %}
{% assign everything = fruits | concat: vegetables %}
{% for item in everything %}
- {{ item }}
{% endfor %}
输出
- apples
- oranges
- peaches
- carrots
- turnips
- potatoes
你可以使用 concat
过滤器链接多个数组:
输入
{% assign furniture = "chairs, tables, shelves" | split: ", " %}
{% assign everything = fruits | concat: vegetables | concat: furniture %}
{% for item in everything %}
- {{ item }}
{% endfor %}
输出
- apples
- oranges
- peaches
- carrots
- turnips
- potatoes
- chairs
- tables
- shelves