Filter: Split a line of text into an array by space

How to split a line of text into an array by space in Anqi CMS template?

fieldsFilters can split a line of text into arrays in a template by spaces. The array defined is a[]string{}, you can traverse the output results in the subsequent process.

How to use

fieldsUsage of filters:

{% set values โ€‹โ€‹= "Text content"|fields %}
{% set values โ€‹โ€‹= "splits the string Anqi CMS"|fields %}
{{values|stringformat:"%#v"}}
# Display result
[]string{"splits", "the", "string", "Anqi CMS"}

Sample Demo

{% set values โ€‹โ€‹= "splits the string ๅ…ญ CMS"|fields %}
{{values|stringformat:"%#v"}}
# Display format
[]string{"splits", "the", "string", "Anqi CMS"}
# Traversal output
{% for item in values โ€‹โ€‹%}
><span>{{item}}</span>/
{% endfor %}
# Display result
splits/ the/ string/ Anqi CMS/