54nd10 / Tailwind-reorder

The Unlicense
10 stars 5 forks source link

Problems with PHP tags and Alpine.js dynamic classes #1

Open davidwebca opened 3 years ago

davidwebca commented 3 years ago

Hi!

I'd be super interested in getting this to work for me since I'm not much of a VSCode fan, but right now, your regex isn't picking up classes correctly and most of the time mangles the code I'm working on. See this simple example with some alpine.js code sprinkled into it:

<button type="button" :class="{ 'active': open  }" @click="toggleOpenClose" class="group p-3 bg-white text-black hover:bg-black hover:text-white header-toggle">
    <span class="sr-only"><?=__('Toggle navigation', 'lang'); ?></span>
    <?php echo wp_svg('menu', 'w-12 h-auto fill-current'); ?>
</button>

Becomes this:

<button type="button" :class="bg-white text-black p-3 'active': @click="toggleOpenClose" class="group header-toggle hover:bg-black hover:text-white open { }"">
    <span class="sr-only "><?=__('Toggle navigation', 'lang'); ?></span>
    <?php echo wp_svg('menu', 'w-12 h-auto fill-current'); ?>
</button>

Might I suggest you sniff into Headwind's code and regexes? I could even create a pull request to add more proper regexes and parametrize them to allow customization in the settings 👀

54nd10 commented 3 years ago

Hi!

I will take a look.

Thanks for your feedback✌️