Jekyll 删除数组中的第一个?

Phi*_*ide 4 liquid jekyll

我注意到remove_first液体中有一个功能。是否可以使用它来删除数组中的第一个?

例如:

{% animals = 'animals/cat/dog/bird' | split: '/' | remove_first %}
Run Code Online (Sandbox Code Playgroud)

以上不起作用,因为您似乎应该传入一个子字符串,就像我使用 split 一样。

有没有办法用 Jekyll 液体标签做到这一点?

mar*_*nuy 6

使用shift

{% assign animals = 'animals/cat/dog/bird' | split: '/' | shift %}
{{animals}}
Run Code Online (Sandbox Code Playgroud)

会给数组:

["cat", "dog", "bird"]
Run Code Online (Sandbox Code Playgroud)