Skip to content
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

[5.4] [POC] Introduce a @prepend for stack #17696

Merged
merged 1 commit into from
Feb 7, 2017
Merged

[5.4] [POC] Introduce a @prepend for stack #17696

merged 1 commit into from
Feb 7, 2017

Conversation

themsaid
Copy link
Member

@themsaid themsaid commented Jan 31, 2017

@push() will add content to the stack starting from the view being rendered, @prepend will add content to the beginning of the stack.

@stack() will display the $prepends in reverse order + the $pushes in normal order.

// layout.blade

@stack('letters')
// master.blade

@extends('layout')

@push('letters', 'A')

@prepend('letters', 'B')
// welcome.blade

@extends('master')

@push('letters', 'C')

@prepend('letters', 'D')

Having View::make('welcome'), the output will be:

BDCA

@GrahamCampbell GrahamCampbell changed the title [5.4][POC] Introduce a @prepend for stack [5.4] [POC] Introduce a @prepend for stack Jan 31, 2017
@GrahamCampbell
Copy link
Member

We shouldn't really keep it being called a stack if it supports prepend. Should be renamed to a deque.

@GrahamCampbell
Copy link
Member

Probably impractical for us to rename it tho, and impossible in 5.4 anyway.

@set0x
Copy link

set0x commented Feb 5, 2017

I need this please. I use stack component in my app for build a breadcrumb system and now i can`t. #17768

@taylorotwell
Copy link
Member

I see @append in the example but I don't see where that was added in the compiler?

@themsaid
Copy link
Member Author

themsaid commented Feb 7, 2017

@taylorotwell sorry it's push not append

@taylorotwell taylorotwell merged commit 7869f6b into laravel:5.4 Feb 7, 2017
@ElfSundae
Copy link
Contributor

Thanks! I think this should be documented in the Blade doc or the Upgrade Guide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants