-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
Blade compilation issues with Tailwind container queries #50171
Comments
Thank you for reporting this issue! As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub. If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team. Thank you! |
I've hit a similar issue in the past where there was a directive defined in the Laravel app that matched one of Tailwinds I had to use Blade's escaping mechanism Not sure what exactly is causing the issue here, though. |
@timacdonald thanks for the suggestion! I gave it a try and unfortunately no change. The compiled output still has the same issues. I even tried changing the |
I've narrowed this down to the following regex in the preg_match_all('/\B@(@?\w+(?:::\w+)?)([ \t]*)(\( ( [\S\s]*? ) \))?/x', $template, $matches); I've been trying to work on tweaking this regex to ignore anything that has a single colon, but retains the double colons. If anyone has any suggestions for ways to accomplish that, I'd love the input. |
It seems to be related to #45490 and further updates of |
i'm using the Tailwind CSS CDN to address that issue |
@aguingand thanks for the heads up on that one. Not sure that changes the fix that I have, but I'll give it another pass and see. @altamisatmaja curious how the Tailwind CDN is addressing the issue for you? |
@agentphoenix I tweaked the regex so that it ignores anything with a single colon but retains the double colons:
Not tested but might help? |
Hi all. Since there's no action on this issue any more we're closing this. We'd still appreciate a PR that could potentially fix this one. Thanks |
Laravel Version
10.45.0
PHP Version
8.3.1
Database Driver & Version
No response
Description
When using Tailwind's container queries plugin with the
@class
directive, Blade either throws exceptions about unexpected endif or simply doesn't compile the classes correct. UsingArr::toCssClasses
directly works as expected.The following examples are in the reproduction repo. (Note: Tailwind isn't installed and configured, but it isn't necessary to show the issues with the Blade compiler.)
Code that works
/success
shows everything working as expected with theArr::toCssClasses
I suspect this is working due to Blade wrapping everything in
e()
.Here's a snippet of the code that works (full example in the repo):
Code that throws an exception
/failure
shows the exception (though this may be compounded by wrapping the HTML in conditionals)Here's a snippet of the code that throws an exception (full example in the repo):
Code that compiles incorrectly
/incorrect
is the same thing as/failure
but without the conditionals (you can see that the content of the@class
call is simply output on the page)Here's a snippet of the code that compiles incorrectly (full example in the repo):
Steps To Reproduce
https://github.com/agentphoenix/class-directive-bug
The text was updated successfully, but these errors were encountered: