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
No need to evaluate a variable two times. #2
Conversation
Example: `docker_upstream|d() and docker_upstream` * When `docker_upstream` is undefined it defaults to false using the Jinja `default` filter. The same applies when `docker_upstream` is False. * When `docker_upstream` is True, it it tested two times for True. * Additionally this change now correctly handles: ```YAML false_var: False docker_upstream: '{{ false_var }}' ```
Looks good. I guess it's time to unlearn another thing... :-) |
No need to evaluate a variable two times.
At least this is shorter and it worked in all my test cases :) |
Hi. You've merged definitely buggy commit :) For example, this commit turns But The same is for the lists. You can't use You can use I have another proposal for conditional brevity:
For example:
|
I agree that recent (as in, the 2.0 Ansible tree, not recent in time) changes to Ansible and Jinja2 parsing made the parser more strict. I guess it's time to unlearn some things. Lots of Thanks for noticing this and detailed explanations in your blog. :) |
I was very wrong about uselessness of So my propositions are slightly simplified :)
|
@dddpaul Yup, that's exactly how I'm using that now. Also remember that |
@dddpaul Thanks for finding my wrong use of the But for the
You might not be aware that there can be unintended side effects here: debops/ansible-owncloud#26 Thanks for the blogposts 😉 |
Example:
docker_upstream|d() and docker_upstream
When
docker_upstream
is undefined it defaults to false using theJinja
default
filter. The same applies whendocker_upstream
is False.When
docker_upstream
is True, it it tested two times for True.Additionally this change now correctly handles: