How to prevent double final newlines in .chezmoitemplates
results
#3249
bradenhilton
started this conversation in
Show and tell
Replies: 1 comment
-
Just add a template comment at the end of the template file:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Many formatters enforce or optionally allow adding a final newline to files.
If you use one of these formatters on a file in your
.chezmoitemplates
directory e.g.:(
\n
used as a visualization only, not included in the actual file contents).chezmoitemplates/file
:and then execute that template inside another template e.g.:
file.tmpl
the resulting file will contain two final newlines:
If you use the template whitespace control characters in your
.tmpl
file e.g.:the resulting file will have no final newlines:
Previously, I was working around this by manually removing the final newline from the
.chezmoitemplates
file, which is every bit as tedious as you might think.If you would like the result to have only a single newline (for clean diffs etc.), you can edit your
.tmpl
file to useincludeTemplate
in combination withtrim
, and remove the whitespace control characters:Beta Was this translation helpful? Give feedback.
All reactions