Skip to content

Change CLASS_NAME_PATTERN to work also for haml templates #38

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

Merged
merged 4 commits into from
Aug 23, 2021

Conversation

wnm
Copy link

@wnm wnm commented Feb 7, 2021

This PR changes the CLASS_NAME_PATTERN to work for haml templates.

Since haml syntax uses dots to chain class names, I first removed the dot from the search pattern...

But, to make sure it still works for decimal spacing classes (e.g. my-1.5), I added a pattern to allow dots which are preceded by a number between 0-3 and followed by a 5.

By looking through the tailwind documentation, I think all the different class patterns are covered by a test already, so I'm not sure how to improve the test coverage... I'm happy to add more tests, but would need some input first, on what to test for...

@wnm wnm force-pushed the new-class-name-regex-for-haml branch from 26aa897 to 083f851 Compare February 7, 2021 14:09
@jumph4x
Copy link

jumph4x commented Feb 15, 2021

Let's link this to #31, I almost got started on this not realizing you made moves already.

Also, thanks for tackling it. ❤️

@wnm
Copy link
Author

wnm commented Feb 16, 2021

ugh, sorry about that I totally forgot to mention this PR in a comment in #31. I don't think I have the permission to link the issue as well...

@jontebol
Copy link

jontebol commented Mar 5, 2021

@wnm, do you think this will also work for slim templates? I would be happy using haml, but inherited a project that uses slim...

@wnm
Copy link
Author

wnm commented Mar 5, 2021

yes, it should work, at least for the default configuration which is using the same syntax for class names as haml, e.g: .class-name

@dhh
Copy link
Member

dhh commented Aug 18, 2021

Happy to see this adapted to the new purger.

@wnm wnm force-pushed the new-class-name-regex-for-haml branch from 9f9cdda to e2786d7 Compare August 23, 2021 09:05
@wnm
Copy link
Author

wnm commented Aug 23, 2021

@dhh done! I also added tests for slim syntax. it has a similar syntax (the same regex works), but better tailwind support

@dhh dhh merged commit 1ace747 into rails:main Aug 23, 2021
Copy link

@krskibin krskibin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

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

Successfully merging this pull request may close these issues.

5 participants