Calculate the number of words in a string

How to calculate the number of words in a string in Anqi CMS template?

wordcountFilters can calculate the number of words in a string.wordcountThe words will be distinguished by spaces. If it does not contain spaces, it is counted as a word. Returns an integer.

How to use

wordcountHow to use filters:

{{ obj|wordcount }}

Sample Demo

{{ ""|wordcount }}
{% filter wordcount %}{% lorem 25 w %}{% endfilter %}

Show results

0
25