Skip to content

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

4 participants