You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To me this is not only a compatibility issue between Twig JS and Twig PHP.
This kind of array comparison helps to write more concise templates:
{# For example: #}
{% if [country, city, place] in [
["France", "Paris", "Palais de l'Élysée"],
["Germany", "Berlin", "Federal Chancellery"],
...
] %}
Official residence
{% endif %}
{# instead of: #}
{% if
(country=="France"andcity=="Paris"andplace=="Palais de l'Élysée")
or (country=="Germany"andcity=="Berlin"andplace=="Federal Chancellery")
...
%}
Official residence
{% endif %}
I suppose I could give an other try to Twing but it is really heavy and I need it on client side.
dorian-marchal
changed the title
Array comparison is broken (in and ==)
Array comparisons (in and ==) are not consistent with TwigPHP
Feb 27, 2020
dorian-marchal
changed the title
Array comparisons (in and ==) are not consistent with TwigPHP
Array comparisons (in and ==) do not conform to TwigPHP
Feb 27, 2020
in
operator doesn't work like Twig PHP when comparing arraysFor example, this evaluates to "true" with Twig PHP but "false" with twig.js:
This falls in this test:
twig.js/src/twig.expression.operator.js
Lines 20 to 23 in 788437f
indexOf
is notundefined
for arrays.Also,
==
operator is broken with array (it only seems to compare array lengths):Evaluates to "true" with twig.js but "false" with Twig PHP.
This time, I think the corresponding code is here:
twig.js/src/twig.expression.operator.js
Lines 170 to 178 in 788437f
The text was updated successfully, but these errors were encountered: