adamchainz / djade

A Django template formatter.
MIT License
283 stars 4 forks source link

Usage with HTML formatter in parralel? #74

Closed ddahan closed 1 month ago

ddahan commented 1 month ago

Description

Thanks a lot for this package! Not really a feature request, but I was wondering what would be the recommendation to handle HTML formatting in addition to Django formatting, using Djade. For example, could I run prettier first then Djade? Or the opposite? Thanks.

adamchainz commented 1 month ago

I don't know right now. I haven't had much luck using HTML formatters, and I'm sceptical about the possibility of formatting correctly.

Last I checked, Prettier's HTML formatting fails on Django templates. I know there's a plugin: https://til.simonwillison.net/npm/prettier-django .

And I don't think that HTML can be correctly formatted without edge cases. Whitespace can be meaningful in any part of an HTML document thanks to CSS white-space: pre, or at least desirable in multiline attributes like https://github.com/rtts/djhtml/issues/92 .

Anyway, if using a formatter, I think running Djade first will make the most sense. Its edits are mostly restricted to the insides of Django tags.