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

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -