How to return a random character from a string or an array in Anqi CMS template?
random
The filter can return a random character, value in a string, array.
How to use
random
How to use filters:
{{ obj|random }}
For example, return[1,2,3,4,5]
Any value in it can be written like this:
{{ "1,2,3,4,5"|split:","|random }}
# 显示结果
2
Sample Demo
{{ 5|random }}
{{ ""|random }}
{{ "h"|random }}
{{ simple.one_item_list|random }}
# 显示结果
5
h
99