Accept structs as root template bindings
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 354
- Forks
- 72
- PR merge metrics
- No merged PRs in 30d
Description
Problem
Public render methods currently require map[string]any root bindings. Struct values work when nested under a map key, but callers cannot pass a struct directly and expose its fields at the template root.
Proposed direction
Add a backward-compatible API that accepts a struct, map, or another supported root object and adapts it to the existing lookup semantics. Existing map-typed methods should remain available.
The behavior should reuse the same field visibility, naming, and struct-tag rules as nested struct values. It should return a clear error for unsupported root kinds rather than panic.
Acceptance criteria
- Existing map-based APIs remain source compatible.
- Public struct fields are available at the root.
- Root and nested structs use consistent field-name rules.
- Pointer, nil-pointer, embedded-field, tag, and conflict cases are tested.
- The implementation does not require eagerly copying every field when the existing value abstraction can provide lookup.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the public render methods and the existing lookup path for nested struct values. Reuse the value abstraction where possible, preserve map-based APIs, and add coverage for root field visibility, naming and tags, pointers, embedded fields, conflicts, nil pointers, and unsupported kinds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100