Refactor to use templ instead of html/template#133
Draft
sumnerevans wants to merge 14 commits intomasterfrom
Draft
Refactor to use templ instead of html/template#133sumnerevans wants to merge 14 commits intomasterfrom
sumnerevans wants to merge 14 commits intomasterfrom
Conversation
a59d525 to
c2112e2
Compare
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>
1ea1182 to
98ebf9a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.