Template autoformatting at buildtime
I hoped to add a jte section to Spotless.
But it looks like the formatter is tied pretty intimately to IntelliJ
- https://github.com/casid/jte-intellij/tree/master/src/main/java/org/jusecase/jte/intellij/language/format
It seems like it would be possible to make a pretty-printer by implementing a TemplateParserVisitor which implements all the callbacks by appending to a big String.
Any thoughts?
@nedtwigg in theorie yes, you could give it a try. For jte parts it should work, but I'm unsure how to format the underlying language (for instance HTML/JS/CSS). The TemplateParser does omit some stuff if configured, so I think the gg.jte.TemplateConfig would need to be set to htmlCommentsPreserved = true and trimControlStructures = false.
Fine to close this if you don't want it implemented, but I've had good luck on some of my projects leaving a seemingly-hopeless feature request open, and eventually somebody comes along and implements it. Canonical formatting has become mainstream (gofmt, rustfmt, prettier, etc), it would be really great if somebody built a jtefmt someday.
If the template is being used in plain text mode it could be rendering anything. You can't generalise format in that case.
True, but HTML is common enough that TemplateConfig has fields like htmlCommentsPreserved. Something can be useful without being universal.
I don't have time to work on it, but will leave it open as @nedtwigg suggested.