Skip to content

Accept structs as root template bindings #51

Description

@abemedia

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions