Skip to content

examples: use provided h helpers instead of raw h.Attr#105

Merged
joaomdsg merged 1 commit into
mainfrom
chore/examples-use-helpers
Jun 10, 2026
Merged

examples: use provided h helpers instead of raw h.Attr#105
joaomdsg merged 1 commit into
mainfrom
chore/examples-use-helpers

Conversation

@joaomdsg

Copy link
Copy Markdown
Member

Follow-up to #104: make the example apps demonstrate effective, idiomatic use of the typed h helpers rather than the stringly-typed h.Attr escape hatch.

A sweep of all 14 internal/examples/* apps + the viashowcase flagship found the examples were mostly clean already; the remaining hand-rolled attributes now have provided helpers. All swaps are behavior-preserving — each helper emits the byte-identical attribute:

  • h.Attr("aria-…", v)h.Aria(name, v)
  • h.Attr("autocomplete"/"alt"/"method"/"action", v)h.AutoComplete/Alt/Method/Action(v)
  • h.Attr("required") / h.Attr("checked")h.Required() / h.Checked()
  • h.Attr("maxlength", "60")h.MaxLength(60); h.Attr("width", …)h.Width(…)

enctype/accept/autofocus/readonly keep h.Attr (no shorthand exists).

Verified: root go build ./... + go test -race ./... green; the viashowcase module builds, vets, and tests green. No behavior change.

Make the example apps (and the viashowcase flagship) model idiomatic use of
the typed attribute helpers rather than the stringly-typed h.Attr escape hatch.
All swaps are behavior-preserving — each helper emits the identical attribute:

- aria-*  → h.Aria(name, val)
- autocomplete/alt/method/action → h.AutoComplete/Alt/Method/Action
- required/checked (boolean) → h.Required()/h.Checked()
- maxlength → h.MaxLength(int); width → h.Width
(enctype/accept/autofocus/readonly keep h.Attr — no shorthand exists.)

Root build + tests and the viashowcase module both green.
@joaomdsg
joaomdsg merged commit bddcebf into main Jun 10, 2026
4 checks passed
@joaomdsg
joaomdsg deleted the chore/examples-use-helpers branch June 10, 2026 11:49
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