How to add two numbers and strings in Anqi CMS template?
add
The filter can add two numbers and strings together.add
You can mix and add integers, floating-point numbers, and strings. That is, when you perform the addition calculation, they can ignore their types, and when the automatic conversion fails, the addition content will be ignored.
How to use
add
How to use filters:
{{ obj|add:obj2 }}
For example5
Plus2
, you can write it like this:
{{ 5|add:2 }} # Show result 7
Sample Demo
{{ 5|add:2 }} {{ 5|add:40 }} {{ 5|add:nothing }} {{ 5|add:"CMS" }} {{ "Anqi"|add:"CMS" }} {{ "Anqi"|add:"2" }} # Show results 7 47 5 5CMS Anqi CMS Anqi2