Skip to content

Migrate templates to Jet v6 with reusable components#79

Draft
retlehs wants to merge 1 commit intomainfrom
reuseable-components
Draft

Migrate templates to Jet v6 with reusable components#79
retlehs wants to merge 1 commit intomainfrom
reuseable-components

Conversation

@retlehs
Copy link
Copy Markdown
Member

@retlehs retlehs commented Mar 29, 2026

Summary

  • Migrate all templates from Go's html/template to Jet v6 (CloudyKit/jet/v6) for first-class parameterized blocks, template inheritance, and C-like expressions
  • Add components.html with four reusable Jet blocks: shell, notice, input, pagination
  • Replace ~110 lines of duplicated HTML across docs, compare, detail, index, and untagged templates
  • Simplify Go-side template loading: single *jet.Set replaces pre-parsed templateSet with 11 template combinations
  • Add buildPagination() helper for pre-computing pagination URLs passed to the pagination component

Why Jet?

html/template has no parameterized components — the previous approach required dict helper functions and trustedHTML workarounds to pass props to shared template blocks. Jet's block/yield with named parameters and default values, plus yield content for slot-based composition, makes reusable components natural:

{{yield shell(command="composer require wp-plugin/woocommerce", variant="amber", class="mb-4")}}

{{yield notice(variant="warning", class="mb-6") content}}
  Your warning content with <strong>HTML</strong> here.
{{end}}

Components

Component Block signature Replaces
shell shell(command, variant="default", class="") 16 duplicated copy-to-clipboard command boxes
notice notice(variant="warning", class="") + yield content 6 duplicated alert/warning boxes
input input(icon, name, value, placeholder, type, showShortcut, id, autocomplete) Duplicated search/filter inputs
pagination pagination(pager, class="") Duplicated pagination controls in 2 partials

Test plan

  • Verify all pages render correctly: index, detail, docs, compare, wordpress-core, untagged, status, admin/logs, 404
  • Verify shell command blocks render and copy-to-clipboard works
  • Verify notice components render with correct variant styling
  • Verify search input with / shortcut works on index and untagged pages
  • Verify author input with autocomplete/clear button works on untagged page
  • Verify HTMX partial loading works (search filtering, pagination on index and untagged)
  • Verify pagination renders correctly with page range ellipsis

🤖 Generated with Claude Code

@retlehs retlehs self-assigned this Mar 29, 2026
@retlehs retlehs force-pushed the reuseable-components branch from 0d868de to 853a7a9 Compare April 5, 2026 19:03
@retlehs retlehs changed the title Add reusable template components with dict helper Migrate templates to Jet v6 with reusable components Apr 5, 2026
Replace Go's html/template with CloudyKit/jet/v6 for server-rendered
templates. Jet provides first-class parameterized blocks, template
inheritance via extends/yield, and C-like expressions — eliminating
the dict helper workarounds that html/template required for reusable
components.

Add components.html with four reusable Jet blocks:
- shell(command, variant, class) — copyable command boxes (replaces
  ~16 duplicated instances across 6 templates)
- notice(variant, class) with yield content — alert boxes with
  variant-based styling and content slots
- input(icon, name, ...) — form inputs with icon and keyboard hint
- pagination(pager, class) — pagination controls driven by
  pre-computed buildPagination() data

Key changes:
- templates.go: embed.FS loader for Jet, function registration via
  AddGlobal, buildPagination() helper, render() using VarMap
- handlers.go: simplified render calls (no more template combinations)
- router.go: *jet.Set replaces *templateSet
- All 13 templates converted to Jet syntax (extends/block/yield)
- Tailwind scanning unaffected (templates remain .html files)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@retlehs retlehs force-pushed the reuseable-components branch from 853a7a9 to 154cb2f Compare April 5, 2026 19:05
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