← All notes

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

Sources

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

Permanent ID: iil:note:vxhy4c40

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.},
}

Markdown

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.

All artifact files (JSON index)

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.