tpl: Rendering Strings from Values
Evaluating template expressions stored in values.
tpl: Rendering Strings from Values is a free Helm Academy lesson on CoddyKit — lesson 2 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.
Templates Inside Values
Sometimes a value in values.yaml itself contains template syntax. By default Helm treats it as a plain string and never evaluates it.
Meet the tpl Function
The tpl function takes a string and a context, then renders that string as a Go template right where you call it.
{{ tpl .Values.greeting . }}It Needs a Context
The second argument to tpl is the scope used during rendering. Passing the root dot lets the string reach Values and Release.
{{ tpl "Hello {{ .Release.Name }}" . }}A Templated Value
Now a user can store a dynamic string in values, like a hostname built from the release name, and have it expand at render time.
host: "{{ .Release.Name }}.example.com"Rendering That Value
In your template, pass that field through tpl with the root context to turn the stored placeholder into a real value.
host: {{ tpl .Values.host . | quote }}Why Not Just Reference It
A direct reference prints the raw braces as text. Only tpl actually evaluates the embedded directives inside the stored string.
Rendering Files Too
You can also feed file contents to tpl, letting a bundled config file include release-specific placeholders.
{{ tpl (.Files.Get "config.tpl") . }}Passing a Custom Scope
The context need not be the root. Pass any dict so the rendered string sees exactly the variables you choose.
{{ tpl .Values.msg (dict "name" "api") }}A Real Use Case
Charts often let users template ingress hosts or annotations this way, keeping flexible config in values rather than templates.
Mind the Errors
If the stored string has a typo, tpl fails at render time, so test with helm template after adding templated values.
Combine with quote
Since a templated host can contain dots or colons, pipe the tpl result through quote so the final YAML value stays a safe string.
host: {{ tpl .Values.host . | quote }}Quick Check
Quick check on tpl behavior.
Recap
You learned that tpl evaluates template strings stored in values or files, using a context you supply such as the root dot. 🎉
Frequently asked questions
Is the “tpl: Rendering Strings from Values” lesson free?
Yes — the full text of “tpl: Rendering Strings from Values” 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 “tpl: Rendering Strings from Values”?
Evaluating template expressions stored in values. 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 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “tpl: Rendering Strings from Values” 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
- Deep Merge with mergeOverwrite and dict
- tpl: Rendering Strings from Values
- Looping Files with range Over .Files.Glob
- fail and Custom Validation Guards