0Pricing
Helm Academy · Lesson

Passing Scope into a Named Template

Sending the right context object to a partial.

Passing Scope into a Named Template is a free Helm Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Helm Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Partials Need Context

A named template can only read what you hand it. The second argument to include is the scope, the dot the partial will see inside.

{{ include "mychart.labels" . }}

The Dot Is the Scope

That trailing dot is the current context. Passing the root dot gives the partial access to .Values, .Release, and .Chart.

Forgetting Scope Breaks Things

If you call a partial without a scope, its dot becomes nil. Any reference to .Values inside then renders empty or errors out.

{{ include "mychart.name" }}

Passing the Root Context

Most helpers expect the whole chart context, so you pass the plain dot. This is the safe default that makes the standard helpers work.

{{ include "mychart.fullname" . }}

Passing a Sub-Object

Sometimes a partial only needs one slice of values. You can hand it a subtree so its dot points at exactly that piece.

{{ include "mychart.ports" .Values.service }}

Inside, the Dot Shifts

When you pass .Values.service, the partial's dot is now that object. It reads .port directly, no longer .Values.service.port.

{{- define "mychart.ports" -}}
port: {{ .port }}
{{- end -}}

Losing the Root on Purpose

Narrowing scope is handy but cuts you off from .Release and global values. The partial only sees the object you passed.

Pass Both With a dict

Need a subtree and the root? Build a small dict and pass that, then reach into each piece by its key inside the partial.

{{ include "mychart.tpl" (dict "top" . "svc" .Values.service) }}

Reading the Bundled Scope

Inside the partial, unpack the dict by key. Now you have the root via .top and your subtree via .svc, both available at once.

{{- define "mychart.tpl" -}}
name: {{ .top.Release.Name }}
port: {{ .svc.port }}
{{- end -}}

Scope Mistakes Are Common

The classic bug is a partial that reads .Release.Name but was called with a narrowed scope. Always check what context you actually passed.

Render to Verify Scope

Run helm template . and confirm the partial output is populated. Empty fields usually mean the wrong scope reached the partial.

helm template my-release .

Quick Check

A partial needs both a subtree and .Release.Name. How do you supply both?

Recap: Passing Scope

The argument after a partial name sets its dot. Pass the root dot, a subtree, or a dict to combine both. Wrong scope means empty output. 🎯

Frequently asked questions

Is the “Passing Scope into a Named Template” lesson free?

Yes — the full text of “Passing Scope into a Named Template” is free to read here on the web, and the Helm Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Helm Academy course, upgrade to CoddyKit PRO.

What will I learn in “Passing Scope into a Named Template”?

Sending the right context object to a partial. You practise Helm Academy 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 Helm Academy?

No prior experience is required. Helm Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Passing Scope into a Named Template” 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 Helm Academy lesson?

Yes. Every Helm Academy 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 Helm Academy