paolotiu / tailwind-intellisense-regex-list

Home Page:https://www.paolotiu.com/blog/get-tailwind-intellisense-anywhere

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Request/Help classList regex

aquaductape opened this issue · comments

For some reason this regex doesn't work on classList property.

{
  "tailwindCSS.experimental.classRegex": [
    "classList={{([^}]+)}}"
  ]
}
<button
  class="p-2 border border-gray-200 rounded-md"
  classList={{ 'p-4': isDark() }}
>
  Lesson
</button>

Then I had a thought that you can't intellisense object string keys, but you can using the class comment hack. So it is possible to intellisense object string keys.

```js
<button
  class="p-2 border border-gray-200 rounded-md"
  // class="
  classList={{ 'p-4': isDark() }}
  //"
>
  Lesson
</button>

But on paper the regex should work as it does here https://regex101.com/r/5I3Fsb/1

Hello, I may found a solution, you can try this regex, it works for me :)

{
  "tailwindCSS.experimental.classRegex": [
    ["classList={{([^;]*)}}", "\\s*?[\"'`]([^\"'`]*).*?:"]
  ]
}

Hope it helps ;)

@paolotiu You may add it to the list of the readme :)

Thanks for this @carere! I'll verify then add it to the README.

@paolotiu Hello, i was wrong with my previous regex, the good one is this one:

{
  "tailwindCSS.experimental.classRegex": [
    ["classList={{([^;]*)}}", "\\s*?[\"'`]([^\"'`]*).:"]
  ],
}

You can test it here

Added it! Thank you so much @carere and @aquaductape <3