timonweb/django-tailwind

Tailwind Automatic Class Sorting

Closed this issue · 3 comments

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

+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?

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

some discussion here prettier/prettier#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