Skip to content
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

Operator "in" not working as expected with "chunk" of text #3037

Closed
DarkBee opened this issue May 29, 2019 · 3 comments
Closed

Operator "in" not working as expected with "chunk" of text #3037

DarkBee opened this issue May 29, 2019 · 3 comments

Comments

@DarkBee
Copy link
Contributor

DarkBee commented May 29, 2019

Consider following snippet

{% set foobar_chunk %}
foobar
{% endset %}

{% set foobar = 'foobar'  %}

{{ 'foo' in foobar_chunk ? 1 : 0 }} {# output : 0 expected 1 #}
{{ 'foo' in foobar ? 1 : 0 }} {# output: 1 expected 1 #}

The fact the first test fails is that foobar_chunk gets converted into a Twig_Markup and the twig_in_filter does not account for it in the source code.

Is the intentional or can we just test if $compare is an instance of Twig_Markup and convert it into a string and then do the test?

@DarkBee DarkBee changed the title Operation "in" not working as expected with "chuck" of text Operation "in" not working as expected with "chunk" of text May 29, 2019
@DarkBee DarkBee changed the title Operation "in" not working as expected with "chunk" of text Operator "in" not working as expected with "chunk" of text May 30, 2019
@fabpot
Copy link
Contributor

fabpot commented Jun 2, 2019

This should work as of Twig 1.40/2.9. Are you using an older version?

@DarkBee
Copy link
Contributor Author

DarkBee commented Jun 2, 2019

Tested this on 2.10.0 on twigfiddle

@fabpot
Copy link
Contributor

fabpot commented Jun 3, 2019

fixed in #3049

@fabpot fabpot closed this as completed Jun 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants