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
song song
4 个月前
0

扫描下方二维码手机阅读文章

0 0