-
-
Notifications
You must be signed in to change notification settings - Fork 304
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
templ generate
takes a long time for unformatted files
#857
Comments
I'd guess it's taking a long time to parse the br tag. The parser currently reads to the end of the content to check if it ever gets closed. If it gets closed and there's content in it, IIRC, the formatter leaves it alone. But if it's a void tag like br, and it's got no children, templ fmt converts it to a self closing tag which is much faster to parse. But several seconds to do either seems like a long time! |
Yep, when i change it to |
There's possibly a way to speed this up by avoiding the rewinding and re-parsing of tags after unclosed tags. Though it may be one of those that adds more parsing complexity than it's worth. |
It could be that as soon as we see a void open tag inside a void tag, eg br inside br, we should quit looking for the close for the first br. |
See #887 |
Thanks a lot! |
Try to generate code for this code
For me it takes 6.3s when it's formatted but after I run
templ fmt
on the file, it takes 4.2ms. It doesn't seem like a big difference but I have a while which takes 1min to generate xd but after I formatted it, it takes only 20ms.templ info
outputusage: templ [...]
templ - build HTML UIs with Go
See docs at https://templ.guide
commands:
generate Generates Go code from templ files
fmt Formats templ files
lsp Starts a language server for templ files
version Prints the version
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: