-
Notifications
You must be signed in to change notification settings - Fork 273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Array comparisons (in
and ==
) do not conform to TwigPHP
#691
Comments
in
operator doesn't work like Twig PHP when comparing arraysin
and ==
)
Twig.js doesn't support Twig comparison rules. They are quite complex (and arguably debatable) because Twig inherits them from PHP. |
OK, I understand. To me this is not only a compatibility issue between Twig JS and Twig PHP. {# 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" and city == "Paris" and place == "Palais de l'Élysée")
or (country == "Germany" and city == "Berlin" and place == "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. |
in
and ==
)in
and ==
) are not consistent with TwigPHP
in
and ==
) are not consistent with TwigPHP in
and ==
) do not conform to TwigPHP
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: