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' -

java - Log4j2 configuration not found when running standalone application builded by shade plugin -

python - How do I create a list index that loops through integers in another list -