i find strange behaviour when using twig (v1.23.3)
in templace have array of objects : use dump function display it, :
<pre align="left" style="text-align: left; font-size: 80%"> {{ dump(current_balances) }} </pre> {% key, val in current_balances %} {{ val.name }} : {{ val.balance | number_format(2, '.', ' ') }} €<br> {% else %} aucun solde trouvĂ©. {% endfor %}
the output of dump expected :
array(2) { [0]=> object(record)#20 (3) { ["name"]=> string(32) "bank 1 - account" ["balance"]=> string(7) "2000.00" } [1]=> object(record)#21 (3) { ["name"]=> string(32) "bank 2 - account" ["balance"]=> string(8) "1000.00" } }
but output of loop not correct. {{ val.name }} displayed, {{ val.balance }} empty.
i dit kind of loops hundreds of time - code merely cut-and-paste template works.
event more curious that, if invert order of vars in object (as matters), putting balance before name, balance displayed, , not name !
don't know one. of course, template rendered controllers calling models, little part of code.
i think found bug, similar variables not replaced in twig template it's hard tell.
that's not bug ! enable cache in twig , looked @ resulting code. guess ? non-printable char has find way near val.balance. "cat -a" on template file shows :
{{ val.name }} : {{m-bm- val.balance }} m-bm-^bm-,<br>$
and result in in compiled template :
$this->getattribute((isset($context[" val"]) ? $context[" val"] : null)
noticed space before val ?
lost 1 hour one. source problem obsolete frenck keymap in debian....
Comments
Post a Comment