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