How to define an array in Anqi CMS template?
listThe filter can define an array in the template. The defined array is a[]string{}and can be traversed to output the results later.
Usage method
listUsage of filters:
{% set values = '["关键词1","关键词2","关键词3"]'|list %}
The string to be converted is enclosed in single or double quotes, using[/]Define the beginning and end of the array, keywords within it should be separated in English,Separate keywords, you can enclose them in quotes or ignore them.
{% set values = '["安企CMS","AnQiCMS","内容管理系统","免费建站系统","免费模板",4,5]'|list %}
{% for item in values %}
<span>{{item}}</span>/
{% endfor %}
# 显示结果
安企CMS/ AnQiCMS/ 内容管理系统/ 免费建站系统/ 免费模板/ 4/ 5/
Example Demonstration
{% set values = '["安企CMS","AnQiCMS","内容管理系统","免费建站系统","免费模板"]'|list %}
# 显示格式:
{{values|stringformat:"%#v"}}
# 遍历输出
{% for item in values %}
<span>{{item}}</span>/
{% endfor %}
# 显示结果
安企CMS/ AnQiCMS/ 内容管理系统/ 免费建站系统/ 免费模板/