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

sql - VB.NET Operand type clash: date is incompatible with int error -

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

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -