Skip to content
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

Template autoformatting at buildtime #209

Open
nedtwigg opened this issue Apr 6, 2023 · 5 comments
Open

Template autoformatting at buildtime #209

nedtwigg opened this issue Apr 6, 2023 · 5 comments
Labels
help wanted Extra attention is needed

Comments

@nedtwigg
Copy link
Contributor

nedtwigg commented Apr 6, 2023

I hoped to add a jte section to Spotless.

But it looks like the formatter is tied pretty intimately to IntelliJ

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?

@casid
Copy link
Owner

casid commented Apr 6, 2023

@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.

@casid casid closed this as completed May 18, 2023
@nedtwigg
Copy link
Contributor Author

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.

@edward3h
Copy link
Contributor

If the template is being used in plain text mode it could be rendering anything. You can't generalise format in that case.

@nedtwigg
Copy link
Contributor Author

True, but HTML is common enough that TemplateConfig has fields like htmlCommentsPreserved. Something can be useful without being universal.

@casid casid reopened this May 23, 2023
@casid
Copy link
Owner

casid commented May 23, 2023

I don't have time to work on it, but will leave it open as @nedtwigg suggested.

@casid casid added the help wanted Extra attention is needed label May 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants