Skip to content

Refactor to use templ instead of html/template#133

Draft
sumnerevans wants to merge 14 commits intomasterfrom
templ-refactor
Draft

Refactor to use templ instead of html/template#133
sumnerevans wants to merge 14 commits intomasterfrom
templ-refactor

Conversation

@sumnerevans
Copy link
Copy Markdown
Contributor

No description provided.

sumnerevans and others added 14 commits April 12, 2026 13:15
Add github.com/a-h/templ v0.2.697 for type-safe HTML templates and
golang.org/x/net v0.52.0 as a direct dependency for test HTML parsing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Bring in templ component equivalents of the HTML templates for: home,
info, authors, rules, register, faq, archive, navbar partial, footer
partial, base layout, and teacher login page.

Update internal/archive.go to remove duplicate type definitions
(Link, WinningTeam, CompetitionResult, YearInfo now live in the
templates package). Add archiveInfo package variable and update
GetArchiveTemplate to convert to the struct types expected by the
html/template renderer.

Add internal/contextkeys/keys.go with context key constants shared by
both the HTTP handlers and the templ components.

The runtime application.go is unchanged and continues to use
html/template; the templ components are not yet wired up.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add testhelpers.CompareHTML which parses HTML fragments into DOM trees
and diffs them structurally, ignoring whitespace-only text nodes,
HTML comments, spurious attributes from HTML syntax errors (e.g. trailing
commas), and normalises CSS class attribute whitespace.

Add equivalence tests for:
- Home page (registration enabled/disabled)
- Register page (registration enabled/disabled)
- Archive page (minimal fixture with 1 year, 2 divisions, 2 teams each)
- Navbar partial (no active page, active home page, logged-in user)
- Teacher login page (no error, email-not-found, email-not-confirmed)

Each test renders the same data with both the old html/template path
(executing the "content" or "navbar" named template) and the new templ
component, then asserts the resulting DOM trees are equivalent.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Sumner Evans <me@sumnerevans.com>
Signed-off-by: Sumner Evans <me@sumnerevans.com>
Signed-off-by: Sumner Evans <me@sumnerevans.com>
Signed-off-by: Sumner Evans <me@sumnerevans.com>
Signed-off-by: Sumner Evans <me@sumnerevans.com>
Signed-off-by: Sumner Evans <me@sumnerevans.com>
Signed-off-by: Sumner Evans <me@sumnerevans.com>
Signed-off-by: Sumner Evans <me@sumnerevans.com>
Signed-off-by: Sumner Evans <me@sumnerevans.com>
Signed-off-by: Sumner Evans <me@sumnerevans.com>
HTML templates deleted by prior templ-refactor commits; equivalence
tests can no longer load them. Convert to pure templ smoke tests that
check rendered output contains expected content.

Also fix navbar.html register link id/class back to registration-link
(matching master) and remove now-unused testhelpers package.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant