Any "COALESCE" like templating function? #4339
Answered
by
twpayne
Lockszmith-GH
asked this question in
Q&A
-
I currently have the following code in my {{- $githubToken := (env "CHEZMOI_GITHUB_ACCESS_TOKEN") -}}
{{- if not ($githubToken) -}}
{{- $githubToken = (env "GITHUB_ACCESS_TOKEN") -}}
{{- end -}}
{{- if not ($githubToken) -}}
{{- $githubToken = (env "GITHUB_TOKEN") -}}
{{- end -}}
{{- if not ($githubToken) -}}
{{- $githubToken = promptStringOnce . "githubToken" "Public GITHUB token (mostly for rate limits - !insecure!)" -}}
{{- end -}} Is there a more efficient syntax for getting the first non-empty value? |
Beta Was this translation helpful? Give feedback.
Answered by
twpayne
Mar 11, 2025
Replies: 1 comment 1 reply
-
The builtin
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Lockszmith-GH
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The builtin
or
function does this. From the docs: