How to add two numbers or strings in Anqi CMS template?
addThe filter can how to add two numbers and strings.addYou can add integers, floating-point numbers, and strings together. It means that when you perform addition calculations, you can ignore their types, and if automatic conversion fails, the content to be added will be ignored.
Usage method
addHow to use the filter:
{{ obj|add:obj2 }}
For example, to convert5Add2It can be written like this:
{{ 5|add:2 }}
# 显示结果
7
Example Demonstration
{{ 5|add:2 }}
{{ 5|add:40 }}
{{ 5|add:nothing }}
{{ 5|add:"CMS" }}
{{ "安企"|add:"CMS" }}
{{ "安企"|add:"2" }}
# 显示结果
7
47
5
5CMS
安企CMS
安企2