Replies: 2 comments 2 replies
-
This is not a bug in chezmoi, but a misunderstanding of Go scoping rules and semantics.
So this will work: $ chezmoi execute-template '
{{- $key := "baz" -}}
{{- if gt 3 1 -}}
{{- $key = "bar" -}}
{{- end -}}
{{ $key }}'
bar Note that this will not do what you expect: $ chezmoi execute-template '
{{- $key := "baz" -}}
{{- if gt 3 1 -}}
{{- $key := "bar" -}}
{{- end -}}
{{ $key }}'
baz The only difference between the use is |
Beta Was this translation helpful? Give feedback.
-
This might not be a bug (one should probably not be using |
Beta Was this translation helpful? Give feedback.
-
So I have some questions...
includeTemplate doen't follow .chezmoiroot
Inside
.chezmoiroot
ishome
, and there ishome/foobar.tmpl
.If I use
{{ includeTemplate "foobar.tmpl" }}
inhome/.chezmoi.toml.tmpl
, chezmoi will report:executing "chezmoi.toml" at <includeTemplate "foobar.tmpl">: error calling includeTemplate: open ~/.local/share/chezmoi/foobar.tmpl: no such file or directory
even if I put it in the
home/.chezmoitemplates
directory. I have to use this instead:{{ includeTemplate "home/foobar.tmpl" }}
This line works in other template files. I guess it's a bug?
{{ $key := value }} doen't work if it's in the {{ if }} {{ end }} directive
This works:
And this not:
chezmoi reports
$foo
is undefined. Is this intentional? I do did a search but there are 200+ issues...Beta Was this translation helpful? Give feedback.
All reactions