Skip to content

Template stack

Jorge Castro edited this page May 1, 2023 · 3 revisions

Stacks

Tag Note
@push('elem') Add the next block to the push stack
@endpush End the push block
@pushonce('elem') Add the next block to the push stack. It is only pushed once.
endpushonce End the pushonce block
@stack('elem') Show the stack
@stack('elem*') Show the stack that starts with the name "elem" (>=4.9)
@push('scripts')
script1
@endpush
@push('scripts')
script2
@endpush
@push('scripts')
script3
@endpush
<hr>
@stack('scripts')
<hr>

It returns

<hr>
script1 script2 script3
<hr>
@pushonce('scripts')
script1
@endpushonce
@pushonce('scripts')
script2
@endpushonce
@pushonce('scripts')
script3
@endpushonce
<hr>
@stack('scripts')
<hr>

It returns

<hr>
script1
<hr>
@push('scripts1')
script1
@endpush
@push('scripts2')
script2
@endpush
@push('scripts3')
script3
@endpush
<hr>
@stack('scripts*')
<hr>

It returns

<hr>
script1 script2 script3
<hr>