-
-
Notifications
You must be signed in to change notification settings - Fork 192
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
Default values for variables #213
Comments
@vascop Not in a general sense right now. For your specific example, that might result in an error if the Either way - this is a good idea! Thanks for logging this issue 🙂 |
I think we need a new func: like hugo's isset
|
@zealic there is |
I think it'd probably work, though much more verbose since we'd have to do the whole "check if it has key and overwrite" dance instead of one-lining the default values. |
@vascop understood. It's not ideal. But it might be the only option... The challenge is that referencing an undefined key will cause Go's
My impression is that we won't be able to get that specific syntax to work without re-implementing Go's templating system. What we can do is have a |
👍 for |
@estahn if But I still think |
Just for future reference, I'm using this to make something like that default case:
|
Wanted to share another option that I found works and is pretty close to the sprig version as well. I'm configuring my datasources as contexts in the config file in this case.
|
Is there a way to use a default value when a variable isn't defined?
Something like:
{{(ds "config").notes | default "this a default note")}}
The text was updated successfully, but these errors were encountered: