简体   繁体   中英

how make addition from 2 variable twig?

Anyone knows how to addition two variable in twig I want to do something like:

{{ var1 }} + {{ var2 }}

Just do it inside the {{ }}

{{ var1 + var2 }}

If you want to assign it to some other variable:

{% set foo = var1 + var2 %}
{{ foo }}

Declaration :

{% set counter = 0 %}

Doing the addition :

{% set counter = counter + 1 %}

For displaying in twig template :

{{ counter }}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM