Skip to content

Stripping leading whitespace in multiline templates #3866

Answered by twpayne
unikitty37 asked this question in Q&A
Discussion options

You must be logged in to vote

Is there a way to get it to strip whitespace on each line? I really don't want to have to put an if…end block for each line!

You need to remove the whitespace yourself, i.e.

{{ if eq .chezmoi.os "darwin" -}}
export A=1
export B=2
export C-3
{{ end }}

See the text/template docs on whitespace for more information.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@unikitty37
Comment options

Answer selected by halostatue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants