a-h / templ

A language for writing HTML user interfaces in Go.
https://templ.guide/
MIT License
8.39k stars 277 forks source link

Accidentally pushing temporary files when using `templ generate --watch` #961

Closed simenandre closed 1 month ago

simenandre commented 1 month ago

I am a big fan of the --watch mode with templ generate, it supports that flow we really are looking for at Padeia. The flow also typically consist of pushing small changes (as a PR), however, since templ generate --watch generates _templ.txt and a different _templ.go file; they are often pushed to a branch (or even to a server, from time to time).

I am not sure how to fix this yet, I have been thinking about maybe we can search for _templ.txt files in a git hook or something? Not sure. Current fix is to let the team know to stop the templ generate --watch command before pushing to git.

However, I thought I'd share the problem we're facing as there might be others having the same issues.

templ info output

(✓) os [ goos=darwin goarch=arm64 ]
(✓) go [ location=/opt/homebrew/bin/go version=go version go1.23.0 darwin/arm64 ]
(✓) gopls [ location=/Users/cobraz/go/bin/gopls version=golang.org/x/tools/gopls v0.16.2 ]
(✓) templ [ location=/Users/cobraz/go/bin/templ version=v0.2.778 ]
joerdav commented 1 month ago

Hey! Thanks for the report.

We have a bit of a conversation ongoing at the moment on this with some PoCs floating around too.

The first plan of attack is to make watch mode generated go files the same as production generated go files. Then the txt files can just be git ignored.

This is being tracked here: https://github.com/a-h/templ/issues/700