Skip to content

refactor: simplify custom HTML template authoring for CalcMark consumers #114

Description

@dvhthomas

Summary

Custom HTML templates (like the Lark playground's lark.gohtml) must duplicate ~80 lines of Go template logic from default.gohtml — block iteration, conditional error/result/diagnostic rendering, frontmatter layout. Error recovery (#112) made this even more complex by adding per-line diagnostics, cascading error classes, and HasLineDiagnostic conditional logic.

Every time the core template structure changes, every custom template must be updated in lockstep or it silently breaks (missing errors, wrong layout, duplicate messages).

Current Pain

The Lark playground template (calcmark-lark/lark.gohtml) is essentially a copy of default.gohtml with different CSS variables and fonts. The structural logic is identical. During #112, the Lark template needed 4 separate updates to stay in sync.

Options to Explore

  • Template inheritance: Base template with {{block}} definitions; custom templates only override CSS/wrapper HTML
  • CSS-only customization: Core owns all template structure; custom templates provide a stylesheet or CSS variables
  • Slots pattern: Core exports named template fragments that custom templates compose
  • Template + CSS separation: Ship the Go template as a fixed contract, custom authors only provide CSS

Context

Discovered during #112 error recovery work. The Lark template needed repeated manual sync with go-calcmark template changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions