templ-templates
Edit and troubleshoot server-side HTML templates (.templ), including regeneration and handler wiring.
When & Why to Use This Skill
This Claude skill streamlines the development and maintenance of server-side HTML templates using the Go 'templ' library. It automates the end-to-end workflow of editing .templ files, regenerating Go code, wiring templates to HTTP handlers, and troubleshooting common integration issues, ensuring a robust and efficient full-stack development process.
Use Cases
- Template Modification: Efficiently edit UI layouts and page templates within the 'internal/adapters/http/templates' directory.
- Automated Code Generation: Resolve compilation errors by automatically triggering 'templ generate' or 'make generate' after template changes.
- Handler Wiring: Seamlessly connect templates to Go HTTP handlers and ensure correct 'text/html' content-type headers are set.
- Error Troubleshooting: Identify and fix common pitfalls like missing *_templ.go files or misplaced business logic within templates.
- CI/CD Integration: Incorporate template regeneration and testing into the standard Go build and test workflow.
| name | templ-templates |
|---|---|
| description | Edit and troubleshoot server-side HTML templates (.templ), including regeneration and handler wiring. |
| license | MIT |
| compatibility | Requires bash, git, Go, and templ. |
| repo | mjrwtf |
| runner | github-copilot-cli |
| version | 1.0 |
| allowed-tools | Bash(git:*) Bash(make:*) Bash(go:*) Bash(templ:*) Read |
Where templates live
- Layouts:
internal/adapters/http/templates/layouts/*.templ - Pages:
internal/adapters/http/templates/pages/*.templ
Standard workflow
- Edit
.templfiles. - Regenerate:
make templ-generate
# or (full): make generate
- Run tests/build:
go build ./...
make test
Handler wiring
- Handlers typically render templates from
internal/infrastructure/http/handlers/*. - Set content type:
text/html; charset=utf-8.
Common pitfalls
- Forgetting to run
templ generate(compile errors referencing missing*_templ.go). - Putting business logic in templates; keep logic in handlers/domain and pass data in.