Templates¶
Overview¶
Sputnik renders template files by replacing variables. Templates are rendered once before the first task runs, and re-rendered on context switch.
Configuration¶
templates:
env:
src: .env.dist
dist: .env
overwrite: always
compose:
src: dev-ops/docker/compose.override.yml.dist
dist: compose.override.yml
overwrite: never
contexts: [dev]
src(required) — source template path (relative to project root)dist(required) — output file pathoverwrite—always(default),never,askcontexts— restrict to specific contexts, null = all
Syntax¶
Variable substitution:
With default value:
Required variable (fails if missing or empty):
If a required variable is not defined, template rendering will fail with an error.
Escape literal braces:
Renders as:PATTERN={{ not_a_variable }}
Overwrite Modes¶
always— overwrite existing files without asking (default)never— skip if file existsask— prompt user for confirmation (interactive mode only)
Context Filtering¶
Templates with a contexts array are only rendered when the current context matches:
Rendering Order¶
- On first task execution — all templates for current context rendered
- On context switch — all templates re-rendered for new context