See user documentation at https://templ.guide
Set the version of templ to the current version.
version setBuild a local version.
version set
cd cmd/templ
go buildBuild and install current version.
# 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.
version set
# Install to $GOPATH/bin or $HOME/go/bin
cd cmd/templ && go installUse goreleaser to build the command line binary using goreleaser.
goreleaser build --snapshot --cleanRun templ generate using local version.
go run ./cmd/templ generate -include-version=falseRun Go tests.
version set
go run ./cmd/templ generate -include-version=false
go test ./...Run Go tests.
version set
go run ./cmd/templ generate -include-version=false
go test ./... -shortRun Go tests.
# 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 totalgotestsum --watch -- -coverprofile=coverage.outRun each fuzz test for FUZZTIME (default 120s).
./parser/v2/fuzz.sh
./parser/v2/goexpression/fuzz.sh
./runtime/fuzzing/fuzz.sh
./internal/jstokenizer/fuzzing/fuzz.shRun the runtime and JavaScript tokenizer fuzz tests against their seed and committed corpora, without fuzzing. These fuzz tests are in separate modules, so that their JavaScript engine and parser dependencies are not dependencies of templ, and go test ./... in the root module doesn't run them. The parser fuzz tests are in the root module, so test and test-cover run their corpora.
(cd runtime/fuzzing && go test ./...) &&
(cd internal/jstokenizer/fuzzing && go test ./...)Run benchmarks.
go run ./cmd/templ generate -include-version=false && go test ./... -bench=. -benchmemRun the templ fmt benchmarks, which include the time taken by prettier.
go test ./internal/format -run '^$' -bench BenchmarkTempl -benchtime 3xFormat all Go and templ code.
gofmt -s -w .
go run ./cmd/templ fmt .Run the lint operations that are run as part of the CI.
golangci-lint run --verboseCheck for known vulnerabilities in dependencies that templ calls.
govulncheck ./...Ensure that templ files have been generated with the local version of templ, and that those files have been added to git.
Requires: generate
git diff --exit-codePush a semantic version number to GitHub to trigger the release process.
version push --prefix="v"Run the development server.
Directory: docs
npm run startBuild production docs site.
Directory: docs
npm run build
