See user documentation at https://templ.guide
Build a local version.
cd cmd/templ
go build
Build and install to ~/bin
rm cmd/templ/lspcmd/*.txt || true
cd cmd/templ && go build -o ~/bin/templ
Use goreleaser to build the command line binary using goreleaser.
goreleaser build --snapshot --clean
Run templ generate using local version.
go run ./cmd/templ generate
Run Go tests.
go run ./cmd/templ generate && go test ./...
Run Go tests.
# Create test profile directories.
mkdir -p coverage/generate
mkdir -p coverage/unit
# Build the test binary.
go build -cover -o ./coverage/templ-cover ./cmd/templ
# Run the covered generate command.
GOCOVERDIR=coverage/generate ./coverage/templ-cover generate
# Run the unit tests.
go test -cover ./... -args -test.gocoverdir="$PWD/coverage/unit"
# Display the combined percentage.
go tool covdata percent -i=./coverage/generate,./coverage/unit
# Generate a text coverage profile for tooling to use.
go tool covdata textfmt -i=./coverage/generate,./coverage/unit -o coverage.out
# Print total
go tool cover -func coverage.out | grep total
Run benchmarks.
go run ./cmd/templ generate && go test ./... -bench=. -benchmem
docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.54 golangci-lint run -v
Create production build with goreleaser.
if [ "${GITHUB_TOKEN}" == "" ]; then echo "No github token, run:"; echo "export GITHUB_TOKEN=`pass github.com/goreleaser_access_token`"; exit 1; fi
./push-tag.sh
goreleaser --clean
Run the development server.
Directory: docs
npm run start
Build production docs site.
Directory: docs
npm run build
Build a Docker container with a full development environment and Neovim setup for testing the LSP.
docker build -t templ:latest .
Run a Docker development container in the current directory.
docker run -p 7474:7474 -v `pwd`:/templ -it --rm templ:latest