Looping Over Lists and Maps with range
Generating repeated YAML from a collection.
Repeat Without Copy-Paste
When a value holds a list, you rarely want to type each entry by hand. The range action loops over a collection and renders YAML for every item.
The range Action
A loop opens with {{ range SOMETHING }} and closes with {{ end }}. The block between them renders once per element in the collection. 🔁
{{ range .Values.hosts }}
- host: {{ . }}
{{ end }}All lessons in this course
- Conditional Blocks with if and else
- Truthiness and Operators in Conditions
- Looping Over Lists and Maps with range
- Scoping a Block with with