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.
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