Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/a-h/templ
A language for writing HTML user interfaces in Go.
https://github.com/a-h/templ
go html-elements htmx ide-support language-server lsp server-side-rendering templating-languages
Last synced: 3 days ago
JSON representation
A language for writing HTML user interfaces in Go.
- Host: GitHub
- URL: https://github.com/a-h/templ
- Owner: a-h
- License: mit
- Created: 2021-04-10T19:37:28.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-10-14T09:48:15.000Z (about 2 months ago)
- Last Synced: 2024-10-29T11:32:47.523Z (about 1 month ago)
- Topics: go, html-elements, htmx, ide-support, language-server, lsp, server-side-rendering, templating-languages
- Language: Go
- Homepage: https://templ.guide/
- Size: 4.27 MB
- Stars: 8,236
- Watchers: 42
- Forks: 272
- Open Issues: 51
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
- awesome-go - templ - A HTML templating language that has great developer tooling. (Template Engines / HTTP Clients)
- awesomeLibrary - templ - A language for writing HTML user interfaces in Go. (语言资源库 / go)
- awesome-ccamel - a-h/templ - A language for writing HTML user interfaces in Go. (Go)
- awesome-go - templ - A HTML templating language that has great developer tooling. Stars:`8.4K`. (Template Engines / HTTP Clients)
- awesome - a-h/templ - A language for writing HTML user interfaces in Go. (Go)
- awesome - a-h/templ - A language for writing HTML user interfaces in Go. (Go)
README
![templ](https://github.com/a-h/templ/raw/main/templ.png)
## An HTML templating language for Go that has great developer tooling.
![templ](ide-demo.gif)
## Documentation
See user documentation at https://templ.guide
## Tasks
### build
Build a local version.
```sh
go run ./get-version > .version
cd cmd/templ
go build
```### nix-update-gomod2nix
```sh
gomod2nix
```### install-snapshot
Build and install current version.
```sh
# Remove templ from the non-standard ~/bin/templ path
# that this command previously used.
rm -f ~/bin/templ
# Clear LSP logs.
rm -f cmd/templ/lspcmd/*.txt
# Update version.
go run ./get-version > .version
# Install to $GOPATH/bin or $HOME/go/bin
cd cmd/templ && go install
```### build-snapshot
Use goreleaser to build the command line binary using goreleaser.
```sh
goreleaser build --snapshot --clean
```### generate
Run templ generate using local version.
```sh
go run ./cmd/templ generate -include-version=false
```### test
Run Go tests.
```sh
go run ./get-version > .version
go run ./cmd/templ generate -include-version=false
go test ./...
```### test-short
Run Go tests.
```sh
go run ./get-version > .version
go run ./cmd/templ generate -include-version=false
go test ./... -short
```### test-cover
Run Go tests.
```sh
# Create test profile directories.
mkdir -p coverage/fmt
mkdir -p coverage/generate
mkdir -p coverage/version
mkdir -p coverage/unit
# Build the test binary.
go build -cover -o ./coverage/templ-cover ./cmd/templ
# Run the covered generate command.
GOCOVERDIR=coverage/fmt ./coverage/templ-cover fmt .
GOCOVERDIR=coverage/generate ./coverage/templ-cover generate -include-version=false
GOCOVERDIR=coverage/version ./coverage/templ-cover version
# Run the unit tests.
go test -cover ./... -coverpkg ./... -args -test.gocoverdir="$PWD/coverage/unit"
# Display the combined percentage.
go tool covdata percent -i=./coverage/fmt,./coverage/generate,./coverage/version,./coverage/unit
# Generate a text coverage profile for tooling to use.
go tool covdata textfmt -i=./coverage/fmt,./coverage/generate,./coverage/version,./coverage/unit -o coverage.out
# Print total
go tool cover -func coverage.out | grep total
```### test-cover-watch
```sh
gotestsum --watch -- -coverprofile=coverage.out
```### benchmark
Run benchmarks.
```sh
go run ./cmd/templ generate -include-version=false && go test ./... -bench=. -benchmem
```### fmt
Format all Go and templ code.
```sh
gofmt -s -w .
go run ./cmd/templ fmt .
```### lint
Run the lint operations that are run as part of the CI.
```sh
golangci-lint run --verbose
```### ensure-generated
Ensure that templ files have been generated with the local version of templ, and that those files have been added to git.
Requires: generate
```sh
git diff --exit-code
```### push-release-tag
Push a semantic version number to Github to trigger the release process.
```sh
./push-tag.sh
```### docs-run
Run the development server.
Directory: docs
```sh
npm run start
```### docs-build
Build production docs site.
Directory: docs
```sh
npm run build
```