MCPcopy Index your code
hub / github.com/a-h/templ

github.com/a-h/templ @v0.3.1020 sqlite

repository ↗ · DeepWiki ↗ · release v0.3.1020 ↗
3,371 symbols 12,321 edges 435 files 772 documented · 23% 3 cross-repo links
README

templ

An HTML templating language for Go that has great developer tooling.

templ

Documentation

See user documentation at https://templ.guide

Go Reference xc compatible Go Coverage Go Report Card

Tasks

version-set

Set the version of templ to the current version.

version set --template="0.3.%d"

build

Build a local version.

version set --template="0.3.%d"
cd cmd/templ
go build

install-snapshot

Build 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 --template="0.3.%d"
# 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.

goreleaser build --snapshot --clean

generate

Run templ generate using local version.

go run ./cmd/templ generate -include-version=false

test

Run Go tests.

version set --template="0.3.%d"
go run ./cmd/templ generate -include-version=false
go test ./...

test-short

Run Go tests.

version set --template="0.3.%d"
go run ./cmd/templ generate -include-version=false
go test ./... -short

test-cover

Run 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 total

test-cover-watch

interactive: true

gotestsum --watch -- -coverprofile=coverage.out

test-fuzz

./parser/v2/fuzz.sh
./parser/v2/goexpression/fuzz.sh

benchmark

Run benchmarks.

go run ./cmd/templ generate -include-version=false && go test ./... -bench=. -benchmem

fmt

Format all Go and templ code.

gofmt -s -w .
go run ./cmd/templ fmt .

lint

Run the lint operations that are run as part of the CI.

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

git diff --exit-code

push-release-tag

Push a semantic version number to GitHub to trigger the release process.

version push --template="0.3.%d" --prefix="v"

docs-run

Run the development server.

Directory: docs

npm run start

docs-build

Build production docs site.

Directory: docs

npm run build

Extension points exported contracts — how you extend this code

Component (Interface)
Types exposed by all components. Component is the interface that all templates implement. [7 implementers]
runtime.go
Node (Interface)
A Node appears within a template, e.g. an StringExpression, Element, IfExpression etc. [17 implementers]
parser/v2/types.go
Renderable (Interface)
The charts all have a `Render(w io.Writer) error` method on them. That method is very similar to templ's Render method. [7 …
examples/integration-go-echarts/main.go
Stream (Interface)
Stream abstracts the transport mechanics from the JSON RPC protocol. A Conn reads and writes messages using the stream [4 …
lsp/jsonrpc2/stream.go
Client (Interface)
Client represents a Language Server Protocol client. [3 implementers]
lsp/protocol/client.go
TemplDocLazyLoader (Interface)
TemplDocLazyLoader lazily loads templ documents as necessary. [1 implementers]
internal/lazyloader/templdoclazyloader.go
Matcher (FuncType)
Matcher is a function that matches HTML nodes.
internal/htmlfind/htmlfind.go
CountService (Interface)
(no doc) [2 implementers]
examples/counter/handlers/default.go

Core symbols most depended-on inside this repo

Run
called by 1001
cmd/templ/fmtcmd/main.go
WriteString
called by 805
runtime/buffer.go
InitializeContext
called by 178
runtime.go
Err
called by 173
lsp/jsonrpc2/conn.go
String
called by 159
runtime.go
GetChildren
called by 155
runtime.go
ClearChildren
called by 153
runtime.go
Error
called by 152
runtime.go

Shape

Function 1,912
Method 846
Struct 502
TypeAlias 58
Interface 37
FuncType 16

Languages

Go77%
TypeScript23%

Modules by API surface

examples/integration-react/static/index.js402 symbols
parser/v2/types.go197 symbols
examples/crud/static/htmx.min.js189 symbols
examples/counter/assets/js/htmx.min.js172 symbols
lsp/protocol/server.go125 symbols
generator/generator.go78 symbols
cmd/templ/lspcmd/proxy/server.go75 symbols
runtime.go73 symbols
lsp/protocol/language.go72 symbols
lsp/protocol/capabilities_client.go63 symbols
lsp/protocol/language_test.go54 symbols
lsp/protocol/general_test.go45 symbols

Used by 3 indexed graphs manifest dependencies, hub-wide

Dependencies from manifests, versioned

github.com/Masterminds/semver/v3v3.1.1 · 1×
github.com/a-h/kvv0.0.0-2025100113101 · 1×
github.com/a-h/parsev0.0.0-2025012215454 · 1×
github.com/a-h/templv0.0.0-0001010100000 · 1×
github.com/akrylysov/algnhsav1.1.0 · 1×
github.com/andybalholm/brotliv1.1.0 · 1×
github.com/andybalholm/cascadiav1.3.3 · 1×
github.com/aws/aws-cdk-go/awscdk/v2v2.25.0 · 1×
github.com/aws/aws-cdk-go/awscdkapigatewayv2alpha/v2v2.25.0-alpha.0 · 1×
github.com/aws/aws-cdk-go/awscdkapigatewayv2integrationsalpha/v2v2.25.0-alpha.0 · 1×

For agents

$ claude mcp add templ \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact