-
-
Notifications
You must be signed in to change notification settings - Fork 280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request: templ fmt should not write the file unless there are changes #128
Comments
This could potentially leverage the outcome of #123 if the hash option is developed. To avoid having to reload the file to do a diff check before writing the file. Although, we do already load the whole file into memory anyway: templ/parser/v2/templatefile.go Line 14 in fc8328a
|
Thanks for the report @jonerer! You're right @joerdav - the fmt command is already holding the file in RAM so it's not much work to do an additional check, and in a lot of cases, it will skip a filesystem write, which should result in a net save of performance overall. I've made a quick tweak to that section of code. |
Thanks for this awesome project -- it feels like a perfect fit for htmx+alpine etc. Love the type safety.
I would like to be able to run
templ fmt
automatically on changes. But right now runningtempl fmt
will trigger a restart ofair
since it rewrites files even though fmt doesn't create any changes. It would be awesome iftempl fmt
doesn't write the file when there's no changes.I believe a change somewhere around here: err = atomic.WriteFile(fileName, w) could fix it.
Ideally I'd like to put something like
cmd = "templ fmt . && templ generate && go build -o ./tmp/main ."
my .air.toml. But right now that causes an infinite loop.
Thanks!
The text was updated successfully, but these errors were encountered: