1 year ago

[Blade] Check if there's something in a stack

Posted 1 year ago by TiborBesze


Is there a way (other than the one I came up with below) to check if there are any data pushed into a Laravel Blade stack?

@if ($__env->yieldPushContent('stack_name') !== '')
    <script src="//path/to/script"></script>

I would like to load a script, but only if there's something pushed into the stack in question. I could push the actual script tag with the pushed content as well, but on some of the pages there would be multiple pushes, and that would result in the same script loaded multiple times for reason.

Any answers would be much appreciated.


Please sign in or create an account to participate in this conversation.