How does whitespace control (`{{-` and `-}}`) work?
BeginnerConceptTemplating: Go Templates & Sprig
Answer
{{- trims all whitespace, including newlines, immediately before the action; -}} trims whitespace after it. Use them on control-flow lines (if, range, end, define) so they do not leave blank lines or break indentation.
metadata:
labels:
{{- include "shop.labels" . | nindent 4 }}
Over-trimming is a classic bug: {{- .Values.x -}} can glue two lines together and produce key: valueother: x. Check with helm template when in doubt.
More on Templating: Go Templates & Sprig
What template language does Helm use?BeginnerWhat does the dot (`.`) mean in a Helm template?BeginnerWhat is `$` and when do you need it?IntermediateHow do `if`, `else if` and `else` evaluate truthiness?BeginnerWhat do `and`, `or`, `not`, `eq`, `ne`, `lt`, `gt` look like in Helm?BeginnerHow does `with` work, and what is its common pitfall?Intermediate