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

Use short-circuit evaluation at And and Or operators. #77

Merged
merged 1 commit into from
Mar 3, 2018

Conversation

bmateusz
Copy link
Contributor

@bmateusz bmateusz commented Mar 3, 2018

The reason of this PR that if we are in strict variables mode, then it is not good to check both sides of an And or Or expression.

Small example:
{% if context.isSpecial and context.special.value == "something" %}

It would not work because the right side is evaluated as well and the strict value check would throw an exception.

Current workaround is a nested if:
{% if context.isSpecial %}{% if context.special.value == "something" %}

That version is too verbose in my opinion.

It does not change the behavior if the strict variable check is turned off.
@bkiers what do you think?

@bkiers
Copy link
Owner

bkiers commented Mar 3, 2018

Yeah, good point!

Thanks @bmateusz.

@bkiers bkiers merged commit c2cbbba into bkiers:master Mar 3, 2018
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.

2 participants