Why does `nindent` exist alongside `indent`?
BeginnerConceptTemplating: Go Templates & Sprig
Answer
indent N prefixes every line with N spaces. nindent N does the same and adds a leading newline. This lets you put the action on the parent key's line and keep the template readable:
resources:
{{- toYaml .Values.resources | nindent 2 }}
Combined with {{-, which removes the preceding newline and spaces, nindent restores exactly one newline and the right indentation. With indent you must start the action at column 0 to avoid doubled indentation.
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 does whitespace control (`{{-` and `-}}`) work?BeginnerHow do `if`, `else if` and `else` evaluate truthiness?BeginnerWhat do `and`, `or`, `not`, `eq`, `ne`, `lt`, `gt` look like in Helm?Beginner