简体   繁体   English

Jekyll在数组中获得位置

[英]Jekyll get position in array

I'm trying to find the position of an element in an array without creating a loop and a conditional inside the loop. 我试图在数组中查找元素的位置,而不在循环内创建循环和条件循环。 I know that languages like java have a method to do this "indexOf" but I was wondering if Jekyll/liquid has something like this. 我知道像Java这样的语言都有执行“ indexOf”的方法,但是我想知道Jekyll / liquid是否具有这样的功能。

Many thanks 非常感谢

Liquid doesn't seem to have such method. 液体似乎没有这种方法。

Even though, it can be implemented with Liquid filters and it will be possible to write it like that: {{ myarray | indexOf: "value" }} 即使可以用Liquid过滤器实现,也可以这样写: {{ myarray | indexOf: "value" }} {{ myarray | indexOf: "value" }} . {{ myarray | indexOf: "value" }}

Cheers 干杯

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM