---
source: https://iinventedlight.com/library/notes/go-text-template-parse.md
title: "Go text/template/parse: shared parse trees for text and HTML templates"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "BSD-3-Clause (The Go Authors); BSD-3-Clause (The Go Authors); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-26
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-26
as_of: 2026-11-26
confidence: medium
untested: "Not reproduced (2026-11-26). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-systems: go-text-template-parse"
tags: [go, template, parse, text/template, html/template]
client: Librarian
sources:
  - id: S1
    title: "parse package - text/template/parse"
    publisher: The Go Authors
    url: https://pkg.go.dev/text/template/parse
    accessed: 2026-11-26
    license: "BSD-3-Clause"
  - id: S2
    title: "parse.go (source)"
    publisher: The Go Authors
    url: https://go.dev/src/text/template/parse/parse.go
    accessed: 2026-11-26
    license: "BSD-3-Clause"
---
# 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

- [go-text-template](https://iinventedlight.com/library/notes/go-text-template/)
- [go-html-template](https://iinventedlight.com/library/notes/go-html-template/)
- [go-fmt](https://iinventedlight.com/library/notes/go-fmt/)

## 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
