-
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
Unsupported use of @php? #22621
Comments
I believe they change |
@devcircus, @mul14, and @GrahamCampbell: thank you all for the time you spent on this. It was exactly the confirmation I needed. |
I found the mention of "inline tags" in the upgrade guide vague, so I googled it and landed here. So I tested this snippet, but it seems that the behavior changed again?
|
Also interesting:
Obviously the |
Ok, hold on. It seems the behavior wasn't changed, it's just unpredictable:
Apparently, when you have an |
see laravel/framework#22621 for further information
In my exploration of the Sage WordPress Starter Theme—a WordPress project that borrows much from Laravel, including introducing Blade as a dependency—I have found an interesting problem. I'm reporting it as a bug instead of a pull request only because I can't think of an easy way to solve the problem, and I'm hoping the community might.
The problem arises from the following (potentially unsupported use case) of the
@php
directive. Consider the following script:When compiling the above, the Blade engine produces something like the following:
Instead of what was expected, e.g.,
I have discovered that this is caused by the regular expression in
BladeCompiler::storePhpBlocks
, which is used to collect all of the template content inside each section of@php
to@endphp
, including sections that span multiple lines of the template.So the conflict seems to be that if one uses the single-tag form of the
@php
directive anywhere in a template, one cannot also use the open/close form of the@php
directive anywhere thereafter in the same template.It's entirely possible that
@php
shouldn't be used in a single-tag form—the Laravel documentation does not say it can be used this way, though it does work, so long as no@endphp
appears in the same template. Maybe instead of this single-tag form, folks should simply use something like{!! functionCall() !!}
instead?The text was updated successfully, but these errors were encountered: