-
Couldn't load subscription status.
- Fork 104
Mimic the behavior of the 'in' operator when applied to strings #214
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
Mimic the behavior of the 'in' operator when applied to strings #214
Conversation
...ead of lists) from original Jinja - search for a substring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels too verbose but I haven't found a simpler way to parse arguments.
I used this place as a reference:
Jinja2Cpp/src/string_converter_filter.cpp
Lines 247 to 253 in 171b5bd
Hi @rmorozov , does this change make sense to you?
luismartingil
commented
Aug 23, 2021
@league55 I believe you're missing changes in the docs too...
@luismartingil This repository has no documentation.
I have checked https://github.com/jinja2cpp/jinja2cpp.github.io , but there is nothing to be updated really, as current documentation just claims compatibility with a Jinja in operator, it doesn't describe it https://github.com/jinja2cpp/jinja2cpp.github.io/blob/master/docs/j2_compatibility.md#current-jinja2-support , So it is still relevant IMO
luismartingil
commented
Aug 24, 2021
@rmorozov Can you please check this PR when you have some time? Thanks!
luismartingil
commented
Aug 24, 2021
@rmorozov All CI checks passed, right? Do you think we can merge it?
In the original Jinja, when the 'in' operator is applied to strings it searches for a substring.
It happens naturally, as a string is a list of chars in Python. This logic wasn't translated to Jinja2cpp right away.
Examples:
AS IS:
EXPECTED:
This PR proposes a fix: expect two possible types of inputs - strings and lists.
Lists are being treated the same way as before, for strings
sequence::find(substring)is applied.