-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Support default variable value during lookup #4712
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
Comments
With environment variables you can already do There's a problem that we don't restrict variable names (perhaps we should) so it's possible that someone has used We also needed to make sure there's no conflict with the extended variable syntax. For example, |
We also needed to decide do we allow the left side to be an extended variable usage like A problem with allowing extended variable usage is that in that expression there can be equal signs as well and knowing what's the default value and what's part of the expression can be complicated. For example, something like Due to all this complexity, I believe the default value syntax should require the left side to be a variable directly. If you really wanted to, you could use nested variables like |
This feature can be quite useful for creating data in file templates. Currently it does not work and fails on:
|
Uh oh!
There was an error while loading. Please reload this page.
We're writing a few test cases which work on a large and nested dictionary which defines pretty much all variables in the test case. This yaml structure is also leveraged in a terraform provider which supports default values if the user does not specify a certain leaf in the data, as well as optional data which might not be filled in at all. This leads to some ugly code in Robot:
or
For things like this a Jinja2-like syntax like
${var | default}
to look up the value from the var${default}
and maybe also${var 'literal'}
to retrieve it from a literal would come handy, using the alternative if${var}
is not defined.I acknowledge the challenge to differentiate a default variable from a default literal (like None), but maybe we can come up with a solution..
The text was updated successfully, but these errors were encountered: