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

Posted 1 year ago by TiborBesze

Hello,

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>
@endif

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.

Thanks

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