Closed arran-nz closed 3 years ago
There are a few options here:
Use the index
function which looks up using strings, e.g.
{{ if (index .theme "bg") }}
{{ end }}
Tell chezmoi to treat missing variables as empty by setting template.options = ["missingkey=zero"]
in your config file.
That's great! Thank you for the prompt reply @twpayne !
Can I ask where you found this information?
Also, while I'm here - Thanks for developing and supporting Chezmoi, It's been a tremendous help configuring my machines and I really appreciate how it was designed!
Seem to have found the documentation for 2.
Thanks for your kind words, I'm happy that chezmoi is helpful for you :)
Please re-open this issue if needed :)
What exactly are you trying to do?
I'm trying to run a portion of a template when a varaible is defined in
~/.config/chezmoi/chezmoi.toml
What have you tried so far?
Where else have you checked for solutions?
Have read this: https://pkg.go.dev/text/template
Output of any commands you've tried with
--verbose
Additional context
Is it possible to reference a variable which does not exist?