how make addition from 2 variable twig?

后端 未结 2 1590
渐次进展
渐次进展 2021-02-07 01:56

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

{{ var1 }} + {{ var2 }}

相关标签:
2条回答
  • 2021-02-07 02:02

    Just do it inside the {{ }}

    {{ var1 + var2 }}
    

    If you want to assign it to some other variable:

    {% set foo = var1 + var2 %}
    {{ foo }}
    
    0 讨论(0)
  • 2021-02-07 02:18

    Declaration :

    {% set counter = 0 %}
    

    Doing the addition :

    {% set counter = counter + 1 %}
    

    For displaying in twig template :

    {{ counter }}
    
    0 讨论(0)
提交回复
热议问题