The most commonly used formatter for Go templates have been prettier-plugin-go-template, but that one is 1. No longer actively maintained (last commit was 3 years ago), 2. Was a little bit of a hazzle to install and 3. Had some quirks inherited from the Prettier HTML formatter that you either loved or hated …
So, I have spent parts of the weekend continuing the works from others and gotten to a state where I’m pretty happy with the output (I have tested this on all of the Hugo embedded templates + all the Hugo docs templates).
It’s still needs some work/more testing, but I appreciate any feedback if you …
Don’t agree with some of the choices I made (and have a convincing argument)
If there isn’t enough time to implement this, I thought it might be a good idea to fork prettier-plugin-go-template and rebuild or update it as a separate npm package. Personally, I think developers should be free to choose between tab and space indentation.
By the way, since I have some expertise in this area, I think I could fork it and handle updates and issue responses.
If start out with something, in my eyes, messy like the above, you shouldn’t be surprised that the output from a new formatter would be different and slightly undefined.
I suggest you do some manual reformatting of this one.