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

Tailwind class sorting #436

Open
steadygaze opened this issue Aug 9, 2024 · 1 comment
Open

Tailwind class sorting #436

steadygaze opened this issue Aug 9, 2024 · 1 comment

Comments

@steadygaze
Copy link

The Tailwind team created a prettier plugin that automatically sorts Tailwind utility classes in a defined order (https://tailwindcss.com/blog/automatic-class-sorting-with-prettier). This has the advantage of not having to think about what order the classes should be in, not having to keep them in the right order manually, and of compressing better if classes always appear in a consistent order.

I was wondering if there was a way to get something like that working in maud, or if it's infeasible. Sadly, doing it the "right" way by extending cargo fmt seems more on the infeasible side because it depends on rust-lang/rustfmt#8, which would let library authors specify how their macros should be formatted.

In something like Askama, the templates look enough like HTML for prettier to work out of the box.

I guess maybe I can create an external program that does this if I care enough, even if that seems hacky.

Another solution I can think of is to reorder classes at compile time in maud, but that is also way too hacky and doesn't have the benefit of sorting them in source.

@steadygaze
Copy link
Author

Actually, I think something like sorting the class names alphabetically in Maud's output is general enough to potentially justify adding to Maud, even if it doesn't do it in Tailwind's semantic ordering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant