Skip to content

Conversation

@browner12
Copy link
Contributor

this new @hasStack directive can be used to wrap @stack directives for conditional output depending on if the stack is empty or not. this can be useful if you want some wrapping code around the stack only if it is not empty.

@hasstack('list')
    <ul>
        @stack('list')
    </ul>
@endif

if you pass content to the stack

@push('list')
    <li>Item 1</li>
@endpush

you will get the output

<ul>
    <li>Item 1</li>
</ul>

but if nothing gets pushed, you'll get no output. this helps avoid the orphaned DOM you may have settled for previously. also helps avoid extra spacing you may have had previously due to gap styling on a parent element.

mimicked the @hasSection directive for naming.

this new `@hasStack` directive can be used to wrap `@stack` directives for conditional output depending on if the stack is empty or not. this can be useful if you want some wrapping code around the stack only if it is not empty.

mimicked the `@hasSection` directive for naming.
@taylorotwell taylorotwell merged commit b194d3f into laravel:12.x Nov 16, 2025
66 checks passed
@browner12 browner12 deleted the AB-has-stack-directive branch November 16, 2025 17:57
browner12 added a commit to browner12/docs that referenced this pull request Nov 16, 2025
taylorotwell added a commit to laravel/docs that referenced this pull request Nov 16, 2025
* add docs for `@hasstack`

document laravel/framework#57788

* Update blade.md

---------

Co-authored-by: Taylor Otwell <taylor@laravel.com>
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.

2 participants