Closed lorypelli closed 2 weeks ago
I added this to the Makefile
and now it works, but the thing I hate is that since it's a CLI command, I need to install it globally with go install github.com/a-h/templ/cmd/templ
No need to install (although I would), you can always use something like:
go run github.com/a-h/templ/cmd/templ@latest generate
If you use VSCode it may be worth you looking into devcontainers as you can encapsulate the dev environment per project.
https://containers.dev/ https://code.visualstudio.com/docs/devcontainers/containers
Here's an example devcontainer config you might use for dev purposes with templ:
{
"name": "Go",
"image": "mcr.microsoft.com/devcontainers/go:1-1-bookworm",
"features": {
"ghcr.io/jungaretti/features/make:1": {},
"ghcr.io/devcontainers-extra/features/go-task:1": {},
"ghcr.io/devcontainers-extra/features/temporal-cli:1": {}
}
}
The config adds 3 'features' for templ, task and make and installs them ready to use within the container. The base container already contains go and you could easily add tailwind as another feature if required.
templ generate
already has a --watch
flag to watch for changes to templ files, and a --cmd
flag to run afterwards.
Perhaps you could clarify what you're looking for?
Add it or make the command automatically run on every go run