[英]Jekyll remove first in array?
我注意到液體中有一個remove_first
函數。 是否可以使用它刪除數組中的第一個?
例如:
{% animals = 'animals/cat/dog/bird' | split: '/' | remove_first %}
上面的方法不起作用,因為似乎您應該傳遞一個子字符串,就像我使用split一樣。
無論如何,Jekyll液體標簽可以做到這一點嗎?
使用shift
:
{% assign animals = 'animals/cat/dog/bird' | split: '/' | shift %}
{{animals}}
將給出數組:
["cat", "dog", "bird"]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.