Liquid: Can I get a random element from an Array?

后端 未结 6 931
甜味超标
甜味超标 2021-02-13 10:49

I\'m trying to pick a random element from an array -- is this possible using Liquid/Jekyll?

I can create an array -- and access a given index ... but is there a way to \

6条回答
  •  感情败类
    2021-02-13 11:31

    The 2018 answer is

    {% assign prefix = page.prefix | sample: 2 %}
    {{ prefix[0] }}
    

    As the OP asked about Jekyll, this can be found at: https://jekyllrb.com/docs/templates/

提交回复
热议问题