Add support for nested layout sections
This commit is contained in:
parent
0a005d570b
commit
c5a1c2a8c0
1 changed files with 10 additions and 2 deletions
|
@ -58,6 +58,7 @@ if ( ! function_exists('extend'))
|
||||||
'layout' => [
|
'layout' => [
|
||||||
'filename' => $layout,
|
'filename' => $layout,
|
||||||
'sections' => [],
|
'sections' => [],
|
||||||
|
'tmp' => [],
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -88,16 +89,23 @@ if ( ! function_exists('section'))
|
||||||
{
|
{
|
||||||
$layout = config('layout');
|
$layout = config('layout');
|
||||||
|
|
||||||
if (array_key_exists($name, $layout['sections']))
|
if (array_key_exists($name, $layout['tmp']))
|
||||||
{
|
{
|
||||||
$layout['sections'][$name][] = ob_get_clean();
|
$layout['sections'][$name][] = ob_get_clean();
|
||||||
|
|
||||||
|
unset($layout['tmp'][$name]);
|
||||||
|
|
||||||
config(['layout' => $layout]);
|
config(['layout' => $layout]);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$layout['sections'][$name] = [];
|
if (empty($layout['sections'][$name]))
|
||||||
|
{
|
||||||
|
$layout['sections'][$name] = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$layout['tmp'][$name] = '';
|
||||||
|
|
||||||
config(['layout' => $layout]);
|
config(['layout' => $layout]);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue