Closed MilkeeyCat closed 2 months ago
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 <br/>
it works MUCH faster, it was my skill issue but thanks for the answer!
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
output usage: templtempl - 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):