Interview Prep/Helm/Templating: Go Templates & Sprig

What is the difference between `include` and `template`?

IntermediateConceptTemplating: Go Templates & Sprig
Answer

template is a Go template action: it writes output directly and cannot be used in a pipeline. include is a Helm function: it returns the rendered string, so you can pipe it into nindent, indent, quote, sha256sum or assign it to a variable.

metadata:
  labels:
    {{- include "shop.labels" . | nindent 4 }}   # works
    {{ template "shop.labels" . }}               # no way to indent multi-line output

Rule in production charts: always use include.

All Helm questions Roadmap: Helm

More on Templating: Go Templates & Sprig