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

Handle Ruby %w syntax in Slim pre processing #17557

Merged
merged 2 commits into from
Apr 4, 2025
Merged

Conversation

RobinMalfait
Copy link
Member

This PR fixes an issue where the Ruby %w[…] syntax causes utilities to not be properly extracted.

This PR will now ensure that it does get extracted correctly.

Given this input:

div[
  class=%w[bg-blue-500 w-10 h-10]
]
div[
  class=%w[w-10 bg-green-500 h-10]
]

Before this PR, we extracted everything but the bg-blue-500. The w-10 was extracted but not because of the second div, but because of the first one.

Fixes: #17542

Test plan

  1. Added a test to ensure it's working correctly.

Looking at the extractor tool, you can see that it now gets extracted correctly. Top is before, bottom is with this change.

image

@RobinMalfait RobinMalfait requested a review from a team as a code owner April 4, 2025 14:43
@RobinMalfait
Copy link
Member Author

For completeness, I don't think this syntax is valid in Pug (but I could be proven wrong). In Haml you can do it, but we already extract it properly:

image

@RobinMalfait RobinMalfait merged commit 7d31725 into main Apr 4, 2025
7 checks passed
@RobinMalfait RobinMalfait deleted the fix/issue-17542 branch April 4, 2025 15:21
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.

Class not extracted when only occurrence is first element of Slim attribute array
2 participants