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

Fix Slim attributes #16985

Merged
merged 6 commits into from
Mar 6, 2025
Merged

Fix Slim attributes #16985

merged 6 commits into from
Mar 6, 2025

Conversation

RobinMalfait
Copy link
Member

This PR fixes an issue in Slim templates where the start of attributes causes some candidates to be missing.

.text-xl.text-red-600[
  data-foo="bar"
]
  | This line should be red

Because of the [ attached to the text-red-600, the text-red-600 was not extracted because [ is not a valid boundary character.

To solve this, we copied the Pug pre processor and created a dedicated Slim pre processor. Next, we ensure that we replace [ with in this scenario (by also making sure that we don't replace [ where it's important).

Additionally, we noticed that . was also replaced inside of arbitrary values such as URLs. This has been fixed for both Pug and Slim.

Fixes: #16975

Test plan

  1. Added failing tests
  2. Existing tests still pass

E.g.:

```slim
.text-xl.text-red-600[
                     ^ This is not part of the candidate
  data-foo="bar"
]
  | This line should be red
```
@RobinMalfait RobinMalfait requested a review from a team as a code owner March 6, 2025 10:36
@RobinMalfait RobinMalfait merged commit af132fb into main Mar 6, 2025
5 checks passed
@RobinMalfait RobinMalfait deleted the fix/issue-16975 branch March 6, 2025 10:59
@mikker
Copy link

mikker commented Mar 6, 2025

Wow! I used to throw a, .x on the end to work around this .flex.items-center.x[value=1] 😅
Happy to see this

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.

4.0.10 - Regression with SLIM templates
3 participants