diff --git a/docs/chart_template_guide/accessing_files.md b/docs/chart_template_guide/accessing_files.md index 6fb63ffc1..206ad0cec 100644 --- a/docs/chart_template_guide/accessing_files.md +++ b/docs/chart_template_guide/accessing_files.md @@ -153,7 +153,7 @@ kind: ConfigMap metadata: name: conf data: -{{ (.Files.Glob "foo/*").AsConfig | indent 2 }} + {{- (.Files.Glob "foo/*").AsConfig | nindent 2 }} --- apiVersion: v1 kind: Secret @@ -161,7 +161,7 @@ metadata: name: very-secret type: Opaque data: -{{ (.Files.Glob "bar/*").AsSecrets | indent 2 }} + {{- (.Files.Glob "bar/*").AsSecrets | nindent 2 }} ``` ## Encoding diff --git a/docs/chart_template_guide/named_templates.md b/docs/chart_template_guide/named_templates.md index 4f8f9f59c..08e41d58d 100644 --- a/docs/chart_template_guide/named_templates.md +++ b/docs/chart_template_guide/named_templates.md @@ -223,7 +223,7 @@ Note that the indentation on `app_version` is wrong in both places. Why? Because To work around this case, Helm provides an alternative to `template` that will import the contents of a template into the present pipeline where it can be passed along to other functions in the pipeline. -Here's the example above, corrected to use `indent` to indent the `mychart_app` template correctly: +Here's the example above, corrected to use `nindent` to indent the `mychart_app` template correctly: ```yaml apiVersion: v1 @@ -231,13 +231,13 @@ kind: ConfigMap metadata: name: {{ .Release.Name }}-configmap labels: -{{ include "mychart.app" . | indent 4 }} + {{- include "mychart.app" . | nindent 4 }} data: myvalue: "Hello World" {{- range $key, $val := .Values.favorite }} {{ $key }}: {{ $val | quote }} {{- end }} -{{ include "mychart.app" . | indent 2 }} + {{- include "mychart.app" . | nindent 2 }} ``` Now the produced YAML is correctly indented for each section: diff --git a/docs/charts_tips_and_tricks.md b/docs/charts_tips_and_tricks.md index 6cab5c423..e948d3bcf 100644 --- a/docs/charts_tips_and_tricks.md +++ b/docs/charts_tips_and_tricks.md @@ -71,12 +71,16 @@ Go template pipelines. To make it possible to include a template, and then perform an operation on that template's output, Helm has a special `include` function: -``` -{{ include "toYaml" $value | indent 2 }} +```gotpl +{{- include "toYaml" $value | nindent 2 }} ``` The above includes a template called `toYaml`, passes it `$value`, and -then passes the output of that template to the `indent` function. +then passes the output of that template to the `nindent` function. Using +the `{{- ... | nindent _n_ }}` pattern makes it easier to read the `include` +in context, because it chomps the whitespace to the left (including the +previous newline), then the `nindent` re-adds the newline and indents +the included content by the requested amount. Because YAML ascribes significance to indentation levels and whitespace, this is one great way to include snippets of code, but handle