osteele / osteele/liquid

Accept structs as root template bindings

Open
#51 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.