Use ErrorTag, AriaInvalid, AriaDisabled, FlashTag across examples#50
Use ErrorTag, AriaInvalid, AriaDisabled, FlashTag across examples#50
Conversation
Replace verbose {{if .lvt.HasError}} / {{if .lvt.HasFlash}} conditional
blocks with concise framework helpers in all affected examples.
- todos: AriaInvalid/ErrorTag for 'text' field, AriaDisabled on Add button
- login: remove state.Error field; use NewFieldError for empty fields,
ctx.SetFlash for wrong password; update template with FlashTag/AriaInvalid
- progressive-enhancement: FlashTag replaces if-blocks, AriaInvalid/ErrorTag/
AriaDisabled on add form
- ws-disabled: same pattern for label and url fields
- flash-messages: replace HasAnyFlash/HasFlash block with four FlashTag calls,
AriaInvalid/ErrorTag/AriaDisabled on item form
Closes #47
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Updates multiple LiveTemplate examples to use the newer template helper functions for rendering flash messages and field validation state, replacing repetitive conditional blocks with concise helper calls.
Changes:
- Replaced
HasFlash/FlashandHasError/Errorconditional blocks withFlashTag,AriaInvalid, andErrorTagin templates. - Added
AriaDisabledusage on submit buttons to reflect invalid form state. - Refactored
loginexample to use field-level errors (NewFieldError) and flash for invalid credentials, removing thestate.Errorfield.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
ws-disabled/ws-disabled.tmpl |
Uses FlashTag, AriaInvalid, ErrorTag, and AriaDisabled to simplify flash + form error rendering. |
todos/todos.tmpl |
Uses AriaInvalid/ErrorTag for the add form and AriaDisabled on the submit button. |
progressive-enhancement/progressive-enhancement.tmpl |
Replaces flash/error conditional blocks with helper tags and adds AriaDisabled to submit. |
login/templates/auth.html |
Displays login errors via FlashTag and field errors via AriaInvalid/ErrorTag; disables submit via AriaDisabled. |
login/main.go |
Removes AuthState.Error; uses NewFieldError for required fields; uses SetFlash("error", ...) for invalid credentials. |
flash-messages/flash.tmpl |
Replaces verbose flash rendering with multiple FlashTag calls; uses AriaInvalid/ErrorTag/AriaDisabled for the input form. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| {{.lvt.FlashTag "success"}} | ||
| {{.lvt.FlashTag "error"}} | ||
| {{.lvt.FlashTag "warning"}} | ||
| {{.lvt.FlashTag "info"}} |
There was a problem hiding this comment.
The flash-messages example documentation is now out of sync with this template change: flash-messages/README.md (and the “About Flash Messages” blockquote in this template) still instructs using .lvt.HasAnyFlash/.lvt.HasFlash/.lvt.Flash, but the template now demonstrates .lvt.FlashTag. Please update the example docs/text to match the new recommended helper (or mention both patterns explicitly).
Update the 'About Flash Messages' info box to mention FlashTag as the recommended rendering helper, while noting the manual HasFlash/Flash pattern for custom use cases. Addresses Copilot review comment. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Closes #47
Changes
Replace verbose
{{if .lvt.HasError}}/{{if .lvt.HasFlash}}conditional blocks with concise framework helpers across all affected examples.Template helpers used
ErrorTag— renders<small>error message</small>or nothingAriaInvalid— rendersaria-invalid="true"when field has error, or nothingAriaDisabled— rendersaria-disabled="true"on submit buttons when any specified field has an errorFlashTag— renders<output role="status|alert">or nothingFiles changed
todos/todos.tmplAriaInvalid/ErrorTagfor "text" field;AriaDisabledon Add buttonlogin/main.gostate.Errorfield; empty fields →NewFieldError; wrong password →ctx.SetFlash("error", ...)login/templates/auth.htmlFlashTag "error"replaces{{.Error}};AriaInvalid/ErrorTagon fields;AriaDisabledon Login buttonprogressive-enhancement/progressive-enhancement.tmplFlashTagreplaces if-blocks;AriaInvalid/ErrorTag/AriaDisabledon add formws-disabled/ws-disabled.tmplflash-messages/flash.tmplFlashTag×4 replacesHasAnyFlash/HasFlashblock;AriaInvalid/ErrorTag/AriaDisabledon item formNot changed
avatar-upload—.Erroris on upload progress entries, not framework field errorschat,counter,live-preview,shared-notepad— no form validation errorsAll 8 example tests pass.