stack()
Renders a stack and optionally clears it
stack(string $name, string $glue = '
', bool $return = false, bool $clear = true): string|null
Parameters
| Name | Type | Default |
|---|---|---|
| $namerequired | string |
no default value |
| $glue | string |
'
'
|
| $return | bool |
false
|
| $clear | bool |
true
|
Return types
stringornull
Examples
Renders everything that has been pushed to the stack with push(), including content that is only pushed later while the template is rendered:
<head>
<?= css('assets/css/index.css') ?>
<?php stack('head') ?>
</head>
// join the entries without line breaks
<?php stack('head', glue: '') ?>
// return instead of echo
<?php $head = stack('head', return: true) ?>
Render a stack more than once
A stack is empty after it has been rendered. To render it in more than one place, pass clear: false to every call but the last:
<?php stack('notices', clear: false) ?>
<!-- … -->
<?php stack('notices') ?>
Read more in the template stacks guide.