DevOps Bootcamp · Lesson

Inserting Partials with template and include

Why include composes with pipelines and template does not.

Lesson 2 of 413 steps

Inserting Partials with template and include is a free DevOps Bootcamp lesson on CoddyKit. This is lesson 2 of 4. Any 3 lessons of this learning path are free to read in full — after that, CoddyKit PRO unlocks every lesson, plus hands-on practice with a built-in code editor and a 24/7 AI tutor. It is part of the DevOps Bootcamp learning path, and your progress syncs across the web and the CoddyKit app. The DevOps Bootcamp course includes 4 lessons in total.

Calling a Partial

A defined partial does nothing until you call it. Helm gives you two actions for this: template and include.

The template Action

The template action renders a named partial inline. You pass the partial name and a scope object for it to read.

{{ template "mychart.labels" . }}

Why template Is Limited

The template action is a statement, not an expression. Its output goes straight to the document and cannot be piped to other functions.

Enter include

Helm adds the include function to fix that gap. It renders the same partials but returns the result as a string you can transform.

{{ include "mychart.labels" . }}

include Composes With Pipelines

Because include returns a value, you can pipe it into functions like indent or nindent. This is why charts almost always prefer include.

{{ include "mychart.labels" . | indent 4 }}

Indentation Is the Real Reason

Inserted YAML must land at the right indent. Only include can be piped to nindent, so it produces correctly nested output every time.

metadata:
  labels:
    {{- include "mychart.labels" . | nindent 4 }}

The Scope Argument

The dot after the partial name is the scope you hand to it. Passing the root dot lets the partial read .Values and .Release.

{{ include "mychart.fullname" . }}

A Helper That Builds a Name

Here a partial returns a name, and a Deployment uses include to drop it into metadata. One source of truth, many callers.

metadata:
  name: {{ include "mychart.fullname" . }}

template Has Its Place

You still see template in the wild, often for partials that emit a full block on their own line where no piping is needed.

{{ template "mychart.notes" . }}

Rule of Thumb

If the output needs indenting or any post-processing, reach for include. Use the plain template action only when you truly do not.

Render to Confirm

Run helm template . and check the partial expanded with the indentation you expected. Misaligned YAML is the classic mistake here.

helm template my-release .

Quick Check

You need to render a partial and indent it under a labels key. Which action works?

Recap: template vs include

Both call partials, but include returns a pipeable string while template only emits inline. Prefer include with nindent for clean YAML. ✨

Free to start

Learn DevOps Bootcamp with an AI tutor — free

Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.

Courses
142
Lessons
568

Frequently Asked Questions

Is the “Inserting Partials with template and include” lesson free?

Yes — any 3 lessons of the DevOps Bootcamp learning path, including “Inserting Partials with template and include”, are free to read in full here on the web. After that, CoddyKit PRO unlocks every lesson, plus interactive practice with a built-in code editor and a 24/7 AI tutor. The DevOps Bootcamp course includes 4 lessons in total.

What will I learn in “Inserting Partials with template and include”?

Why include composes with pipelines and template does not. You practise DevOps Bootcamp with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start DevOps Bootcamp?

No prior experience is required. DevOps Bootcamp on CoddyKit is structured for beginners through advanced learners, so you can start here or from the beginning and move at your own pace. This is lesson 2 of 4.

How long does the “Inserting Partials with template and include” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this DevOps Bootcamp lesson?

Yes. Every DevOps Bootcamp lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Defining a Partial with define
  2. Inserting Partials with template and include
  3. The Standard Fullname and Labels Helpers
  4. Passing Scope into a Named Template
← Back to DevOps Bootcamp