Sage: Unsupported use of @php directive

Created on 3 Jan 2018  路  3Comments  路  Source: roots/sage

Dear amazing people at Roots;

I want to draw your attention to this issue I reported in the Laravel project. It seems using the @php directive in what I've been calling the "single-tag-form" is no longer supported. The reason being that if there are any @endphp closing tags used in the same template, all of the content between the first @php and the last @endphp will be evaluated by the compiler to be of the same directive, resulting in unintended behavior, e.g., the intervening template code being printed to the screen.

Here's an example of the way you're using it:

https://github.com/roots/sage/blob/42db9f9c991202fda1e4939b556b85b979dab6cb/resources/views/layouts/app.blade.php#L2

This way that you're using the @php directive is functional, but only in isolation to the block-form that includes both the @php and @endphp tags.

Most helpful comment

Hi @collegeman,

It looks like the issue template is missing from this issue. Please take a look at the Contribution Guidelines, which will tell you exactly what your ticket has to contain in order to be processable.

Please do not use the issue tracker for personal support requests (use the Roots Discourse to ask the Roots Community for help, or if you want the Roots Team to dedicate some time to your issue, we offer our services as well).

All 3 comments

Hi @collegeman,

It looks like the issue template is missing from this issue. Please take a look at the Contribution Guidelines, which will tell you exactly what your ticket has to contain in order to be processable.

Please do not use the issue tracker for personal support requests (use the Roots Discourse to ask the Roots Community for help, or if you want the Roots Team to dedicate some time to your issue, we offer our services as well).

@roots-ladybug spanked me! 馃悶

Also if you're using vscode and the Laravel Blade Snippets extension, emmet won't recognize anything after a @php() directive as "blade". Therefore snippets won't work and syntax highlighting is funny, for example comment syntax will be like
// foo
instead of
{{-- foo --}}

That's why I changed all the @php() directives to @php @endphp tags.
(Just in case anyone stumbles upon this as well and spent as much time as I figuring out why emmet wasn't working in my blade views.)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

oxyc picture oxyc  路  4Comments

evertsemeijn picture evertsemeijn  路  3Comments

timalbert picture timalbert  路  6Comments

Geczy picture Geczy  路  5Comments

buckedup picture buckedup  路  3Comments