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

Parse leading negatives #896

Merged
merged 11 commits into from
Jul 21, 2022
Merged

Parse leading negatives #896

merged 11 commits into from
Jul 21, 2022

Conversation

tkindy
Copy link
Contributor

@tkindy tkindy commented Jul 20, 2022

Closes #892
Depends on #895

Currently, the expression {{ -10 }} is interpreted by Jinjava as 10 with leading whitespace removed when it should be interpreted as -10. The problem is that Jinjava interprets the unary minus as a whitespace control character because the parser is lenient about whitespace between the tag and the dash.

This PR adjusts the whitespace control character parsing to require no space between the tag and the control character. This aligns with Jinja's behavior:

You must not add whitespace between the tag and the minus sign.

@tkindy tkindy requested a review from jasmith-hs July 20, 2022 17:49
@tkindy tkindy force-pushed the tk/whitespace-control-negative-bug branch from 7dfe3c6 to bacaad5 Compare July 21, 2022 20:26
Base automatically changed from tk/fix-operator-precedence to master July 21, 2022 20:27
@tkindy tkindy force-pushed the tk/whitespace-control-negative-bug branch from bacaad5 to 0c9d70b Compare July 21, 2022 20:27
@tkindy tkindy merged commit c7bc01c into master Jul 21, 2022
@tkindy tkindy deleted the tk/whitespace-control-negative-bug branch July 21, 2022 20:33
tkindy added a commit that referenced this pull request Jul 22, 2022
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.

Unary minus operator at beginning of expression is ignored
2 participants