我注意到有一个 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"]
关于Jekyll 删除数组中的第一个?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44875698/