What Is a Template Variable? Explained
A template variable is a named placeholder in a template that a templating engine replaces with a concrete value to produce final text.
A template variable lets you write one file with blanks to fill in, then generate many concrete versions from it. A templating engine reads the template, looks up each variable, and substitutes the value. CI relies on this to render config, manifests, and reports per environment - one template, different values for staging and production.
What a template variable is
A template variable is a placeholder written in a templating syntax, often double curly braces around a name, embedded in otherwise static text. The engine replaces each placeholder with a supplied value, producing the final rendered output. The template stays reusable; only the values change.
Templating engines
Many engines exist - Jinja, Go templates, Handlebars, and Helms templating among them. Beyond simple substitution they often support conditionals, loops, and functions, so a template can adapt its structure, not just its values. The engine defines the exact placeholder syntax and capabilities.
Templating versus interpolation
They overlap but differ in scope. Shell or CI interpolation substitutes environment variables into commands at run time. Templating is a deliberate render step that produces a whole file from a template and a set of values, usually with richer logic like loops and conditionals.
Template variables in CI
Pipelines render templates to produce environment-specific config: a Kubernetes manifest per environment, a deploy config with the right region, or a release notes file from a template plus the version. A render step fills the variables, then a later step applies or publishes the result.
# Render a template with values in a CI step
steps:
- run: |
export VERSION=1.4.0
envsubst < deploy.tpl.yml > deploy.yml
- run: kubectl apply -f deploy.ymlLatchkey note
Templating tools like envsubst, Jinja, or Helm are plain CLIs your job installs, and on Latchkey those tool and dependency downloads are cached between runs so a render step stays fast.
Key takeaways
- A template variable is a named placeholder a templating engine replaces with a concrete value.
- Templating engines add logic like conditionals and loops beyond simple substitution.
- CI renders templates to produce per-environment config and files, then applies the result.