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

Handle spaces better in for loop expressions #706

Merged
merged 3 commits into from
Jul 13, 2021
Merged

Conversation

jasmith-hs
Copy link
Contributor

The logic for "For loop" expressions is pretty wonky. Let's clean it up a bit and allow Jinjava to support for loops with maps that contain spaces. For example:

{% for item in [{'key': 'foo?'}, {'key': 'bar?'}] %}

Currently this gets transformed into:

{% for item in [{'key':,'foo?'},{'key':,'bar?'}] %}

which is invalid syntax. (Notice the commas after the colons)
This PR makes that not happen by never splitting up the expression. Instead we look for " in " and treat everything after that as the loop expression. The previous logic did this, but in a more convoluted way by first splitting up all the helpers (treating spaces and commas the same way) and then rejoining them with commas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant