timonweb / django-tailwind

Django + Tailwind CSS = 💚
https://django-tailwind.readthedocs.io
MIT License
1.45k stars 89 forks source link

Tailwind Automatic Class Sorting #130

Closed Khoding closed 2 years ago

Khoding commented 2 years ago

Tailwind Devs made a Prettier plugin that automatically orders tailwind classes in a convenient order. Problem is that Django doesn't have any proper template prettier that doesn't break stuff, so it's not easy to setup.

My question is has anyone managed to setup it for their codebase, and also wouldn't it be useful to make an actual Django prettier plugin that works well with tailwind class sorting? (Note that the only thing I know about this is that it takes a tremendous amount of work 😂 but I'd be happy to even learn a whole new language if that's what it takes to make it work, as long as someone does it with me)

Link to the article about the auto sorter: https://tailwindcss.com/blog/automatic-class-sorting-with-prettier. Btw I tried it in a different codebase that's not with Django, and it's extremely helpful, knowing where to find each kind of classes is literally a life saver after a few hours using Tailwind in a row

lapinvert commented 1 year ago

+1 this plugin is a must have to any tailwind user. @Khoding have you found a way to make it work with django-tailwind ?

@timonweb Do you know to make it work?

Khoding commented 1 year ago

@lapinvert I have not, but if you do, let me know

anentropic commented 1 year ago

some discussion here https://github.com/prettier/prettier/issues/5754 basically suggesting just use HTML syntax for django templates and put prettier-ignore comments anywhere that breaks... it's probably the only pragmatic option for now

there are also some template langs with similar syntax (jinja2, nunjucks, twig) which be close enough to use with Django templates (and Django can also be configured to use jinja2 templates)

I'm not sure what state any of these plugins are in (some not great probably)

and then they probably need some help to interact correctly with the tailwind plugin