Template action
A template action is a delimited instruction in a template that evaluates data, expressions, control flow, definitions, or function calls.
Learn Go with Pocket-Sized Projects
A template action is a delimited instruction in a template that evaluates data, control flow, definitions, or function calls.
- How it is used
- Uses delimited actions to generate structured output from data instead of cumbersome fmt.Sprintf or strings.Builder code.
- How deep it goes
- Explains parsing, execution, dot-based interpolation, field access, iteration, conditionals, and scoped contexts.
- Examples
- Demonstrates {{.}} in an HTML habits page and executes it with the value 5.
- What you can do after
- Apply it via Go templates to interpolate values and express conditionals, iteration, field access, and scoped output.
Read how Learn Go with Pocket-Sized Projects explains template action →
Go in Practice, Second Edition
A Go action is a command or data expression enclosed in double curly brackets within a Go template.
- How it is used
- Uses double-curly-bracket expressions to render, iterate, format, and control values in HTML templates.
- How deep it goes
- Explains field actions, range iteration, pipelines, custom functions, and context-aware escaping without detailing the complete action language.
- Examples
- Demonstrates title and content fields, comment iteration, URL escaping, HTML escaping, and custom date formatting.
- What you can do after
- Build HTML templates that render data, iterate collections, apply pipelines, and call registered Go formatting functions.
Read how Go in Practice, Second Edition explains template action →
Related concepts
- define actionincludes · A define action is a Go template action that declares a named template body terminated by an end action.
- templatepart of · A template is a reusable structure with fixed elements and variable parts for creating or generating similar content, outputs, or artifacts.
- pipelineuses · A pipeline is an ordered or coordinated sequence of connected processing stages or tasks that passes data, work, or results toward an outcome.
- template dotused by · The template dot is the Go template data-context expression representing the current value available to template actions.
- instructionkind of · An instruction is a directive that specifies an action, task, operation, constraint, or expected behavior for a person or computational system.
- compiler directivekind of · A compiler directive is a source-level instruction that controls compilation or directs related tooling without being an ordinary executable statement.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

