Return a random character, value from a string or array

How to return a random character, value from a string or array in AnQi CMS template?

randomThe filter can return a random character, value from a string or array.

Usage method

randomHow to use the filter:

{{ obj|random }}

For example, return[1,2,3,4,5]If any value in the middle, it can be written like this:

{{ "1,2,3,4,5"|split:","|random }}
# 显示结果
2

Example Demonstration

{{ 5|random }}
{{ ""|random }}
{{ "h"|random }}
{{ simple.one_item_list|random }}
# 显示结果
5

h
99