简体   繁体   中英

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.

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" }} {{ myarray | indexOf: "value" }} .

Cheers

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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