php - Twig Assignment operator -


i want calculate total numbers specific field in twig

in php template, can make so

  <?php $tl = 0; ?>   <?php foreach($loo $l):>   <?php $tl += $l['amount'] ?>   <tr>     <td><?php echo $l['amount'] ?>   </tr>   <?php endforeach ?>    <p><?php echo number_format($tl,2) ?> 

how in twig?

i tried

 {% set tl = 0 %}     {% task in tasks %}        {% set tl += {{ task.amount }} %}      {% endfor %}     {{ tl }} 

it doesn't work ideas?

looks twig doesn't support combined operators php do. (i not find example in http://twig.sensiolabs.org/doc/templates.html#setting-variables)

maybe relevant: how make addition 2 variable twig?

could use try separate operator version?

{% set tl = tl + task.amount %} 

Comments

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

Making Empty C++ Project: General exception (Exception from HRESULT:0x80131500) Visual Studio Community 2015 -

How to fix java warning for "The value of the local variable is not used " -