concat串联数组

concat串联数组

ZKEASOFT August 28, 2018


concat

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

可以多次使用连接多个数组

输入

{% 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

微信公众号