Framework: Blade directives stack and push not working as of 5.2.27

Created on 31 Mar 2016  路  33Comments  路  Source: laravel/framework

after upgrading 5.2.27 now @stack and @push directives in blade no longer working.

Downgraded to 5.2.26 , and its working again.

bug needs more info

Most helpful comment

the command "php artisan view:clear" fixed this for me after updating from 5.2.26 to 5.2.29

All 33 comments

How it no work?

It is working

They had a bug fix in them recently. I assume you were relying on the old broken behaviour?

Hi ... I have the same issue .... The javascript contained within the @push('scripts') and the @endpush are not rendered on the page ...... Was working before the update .... Where can I find what the "structure" must be

@arnoldjp57 Could you try cleaning your view cache then test again?

Could you try cleaning your view cache then test again?

If that's needed, then we have a bug anyway surely?

Can anyone produce a small reproducible sample please?

@GrahamCampbell Yap, I'm wondering whether the compiler compile the child template (due to child template update), but remain its parent template (due to no update)

Hope someone can reproduce the bug

Wouldn't this change _require_ everyone to clear their view cache? All the compiled templates will still be using "sections" for pushes even though the Blade compiler has changed.

Ping @mark86092.

I think we'll probably have to revert this and do it on master. I assume its breaking because people are required to clear their view cache? We need feedback ASAP @mark86092.

screen shot 2016-04-02 at 6 24 08 am

These changes is clearly breaking, and there no update to Factory:: yieldContent() to handle @stack() as an alias to @section() for backward compatibility. Not to mention startSection vs startPush and appendSection vs stopPush.

I think we'll probably have to revert this and do it on master.

If we do this, then people who already reset/clear the views would have to redo it again.

The best approach is to make this backward compatible by calling yieldPushContent() from yieldContent(). This way if the child template (where you use @push()) got the update was updated and not the main template (where you use @stack()), it would still works.

However, it still doesn't solve if the main template (@stack()) was updated but no the child template (@push()). If we call yieldContent() from yieldPushContent() that would cause an infinite loop between the two.

All the compiled templates will still be using "sections" for pushes even though the Blade compiler has changed.

Extending of @taylorotwell says, I get a question about the flow:

Update to 5.2.27 -> Modify some file -> Deploy your website

How can we deploy with only some cache remain and the cache break?


Below is the two points,

  1. I'm sorry to say that any template use @push is necessarily recompiled
  2. And the @stack can work with yieldContent, thank @crynobone hint

Reason for 1:

If I have a fix that make @push working with section, take a example,

>> a.blade.php
@stack('me')
>> b.blade.php
@extends('a')
@push('me') b0 @endpush('me')
>> c.blade.php
@extends('b')
@push('me') c1 @endpush('me')
@push('me') c2 @endpush('me')

If someone update (then recompile) c.blade.php, and remain b.bldae.php.
The compiled part of b.blade.php remain,

$__env->startSection('me'); b0 $__env->appendSection('me');

Then you can still expect "c1 c2 b0"

I think we'll probably have to revert this and do it on master.

Yap, someone update to 5.2.27 need clean their cache, because of missing startPush... But safe to go to master

It makes me headache about how to fix push but remain @push compile to appendSection

I have done php artisan view:clear and now any view that I have that uses datatables server side does not render the required

@arnoldjp57 Do you use @stack for your @push, or use @yield ?

Hi .....
@push('scripts')

@endpush
@stop

@arnoldjp57 What is @stop here doing? I mean what syntax do you use to yield your @push content.

This is the start of the javascript
image

This is the end of the javascript
image

When I copied and pasted into the previous comment, all the javascript disappeared ... :-)

I don't know if it is related but when using @push in an included view and in the view itself , order of push is reversed, for example :

jquery.blade.php

@push('scripts')
<script src="jquery.min.js"></script>
@endpush

script.blade.php

@extends('layout')
@include('jquery')
@push('scripts')
<script>
    $(function(){ alert('ok') });
</script>
@endpush

@stack('scripts') compiled in layout.blade.php will be :

<script>
    $(function(){ alert('ok') });
</script>
<script src="jquery.min.js"></script>

Only on Laravel >= 5.2.27

@sebastienheyd You're right, @include will increase renderCount, same as @extends does, renderCount determine the position of each @push block

Ping @taylorotwell The problem now is complicated.
If fix, @push with @include is weird, if no fix, @push with @extends is weird.

5.2.29 still not rendering @push .... Has the issue been resolved and the structure I use is incorrect?
I have a main layout.blade.php that is used of all forms
.....
@include('navbar')
@yield('content')
@yield('scripts')

navbar.blade.php has no "@" directives

the form I am having issues with has

@extends('layout')
@section('content')
@push('scripts')
@endpush
@stop

Any idea's ? 5.2.26 working ok

@arnoldjp57 I asked you several times how you yield your @push, you should use @stack not @yield

Hi ... Sorry, didn't get what you meant previously .... Have changed @yield('scripts') to @stack('scripts') in the the master layout and it is now working ... Thank you ....

the command "php artisan view:clear" fixed this for me after updating from 5.2.26 to 5.2.29

What is the difference between $__env->yieldPushContent( ) and yieldContent and @push?

@Abdullah-Alig heya. This issue is pretty old so I'm closing it down. It's best to ask those kind of questions in a forum or chat like the Laravel server on Discord or Larachat.

Was this page helpful?
0 / 5 - 0 ratings