Skip to content
Discussion options

You must be logged in to vote

While not possible to use chezmoi's built-in post-init templating context, the rest of the quote on the .chezmoidata pages state:

... Dynamic environment data should be read from templates using the output, fromJson, fromYaml, or similar functions

Below is an example of using fromYaml:

My .chezmoidata/choices.yaml contains:

choices:
  flags:
    - "one"
    - "two"
    - "three"

Dynamic loading (can be done in .chezmoi.toml.tmpl)

> cz execute-template '{{-
  $choices := (list .chezmoi.sourceDir ".chezmoidata" "choices.yaml" | join "/" | include | fromYaml).choices
-}}{{- $choices.flags -}}
'
[one two three]

.chezmoidata availablility in the post-init template engine

> chezmoi execute-…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Lockszmith-GH
Comment options

Answer selected by Lockszmith-GH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant