Go text/template/parse: shared parse trees for text and HTML templates
Answer: Package parse builds the parse trees used by text/template and html/template, but those public packages are what clients should call.
Intended audience
This package holds shared internal data structures that are not meant for general use.
Clients should use text/template and html/template to construct templates rather than this package.
A parse helper assigns the given name to the top-level template.
If parsing hits an error, it stops and returns an empty map along with that error.
Nodes in the tree
ActionNode represents an action, meaning something bounded by delimiters, and it holds a pipeline.
Some nodes hold a pipeline to be evaluated and a list of what to execute if the value is non-empty.
Field names in the tree may be chained, as in .x.y.
NodeAction is a non-control action such as a field evaluation.
NewIdentifier is a public method so we cannot modify its signature casually.
Empty action delimiter strings fall back to the defaults {{ and }}.
See also
Claims
- id: C1 claim: This package exists to share parse trees, not to be the public template API. source: S1 evidence: "Package parse builds parse trees for templates as defined by text/template and html/template."
- id: C2 claim: A parse error stops the parse and yields an empty map. source: S1 evidence: "parsing stops and an empty map is returned with the error."
- id: C3 claim: The package documentation describes parse trees for templates. source: S2 evidence: "Package parse builds parse trees for templates"
Sources
- [S1] parse package - text/template/parse. The Go Authors. https://pkg.go.dev/text/template/parse . License: BSD-3-Clause. Accessed 2026-11-26.
- [S2] parse.go (source). The Go Authors. https://go.dev/src/text/template/parse/parse.go . License: BSD-3-Clause. Accessed 2026-11-26.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: The Go Authors, parse package - text/template/parse; The Go Authors, parse.go (source). BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: The Go Authors, parse package - text/template/parse; The Go Authors, parse.go (source). BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors.
Cite this
iinventedlight. 2026. "Go text/template/parse: shared parse trees for text and HTML templates." iinventedlight Library, iil:note:vxhy4c40, version of 2026-11-26. https://iinventedlight.com/library/notes/go-text-template-parse/. License: CC-BY-4.0.
@misc{iil_note_vxhy4c40,
author = {{iinventedlight}},
title = {{Go text/template/parse: shared parse trees for text and HTML templates}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-26},
url = {https://iinventedlight.com/library/notes/go-text-template-parse/},
note = {Permanent ID iil:note:vxhy4c40. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- go-text-template-parse.schema.json (schema; CC-BY-4.0)
- go-text-template-parse.table.json (table; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/go-text-template-parse.md.