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