airblade / tcs

Tailwind class sorter - sorts the classes in your HTML into Tailwind's recommended class order, without Prettier
MIT License
8 stars 0 forks source link

Add support for other HTML sources #1

Open airblade opened 1 year ago

airblade commented 1 year ago

E.g. Slim templates, Rails helpers.

airblade commented 1 year ago

Rails: the CLASS_LIST regex needs to find class: "..."

https://github.com/airblade/tcs/blob/f1b1c3085631d84ad0c38f02a942114f50f699eb/tcs#L16

Remember Slim templates can contain HTML tags.

airblade commented 1 year ago

It's impossible to support Slim's class shortcut because the . separating class names is the same as the . within Tailwind class names such as w-1.5.

∴ If you want to use tcs with Slim, you need to write out the class names using the class="..." attribute.

bb commented 1 year ago

Maybe you could make special rules for \d+\.\d+ to be treated as one and also parse parentheses and not split class names inside those?

airblade commented 1 year ago

Maybe you could make special rules for \d+.\d+ to be treated as one and also parse parentheses and not split class names inside those?

Personally I find with Tailwind projects that class="foo bar baz" is much easier to read than .foo.bar.baz anyway.

I'll look into it.

airblade commented 1 year ago

@bb As far as I'm aware Slim itself doesn't support class names containing .. I know we discussed it previously over here while talking about Tailwind's arbitrary values. And if Slim doesn't support it, I can't see a reason to support it here.

airblade commented 1 year ago

(I didn't mean to close this.)