- Made some bugfixes regarding blocks and slots
This commit is contained in:
parent
18a0fd7fdc
commit
48ecd9f7d9
|
@ -24,14 +24,13 @@ class BlockToken implements ControlStructure {
|
||||||
return <<<PHP
|
return <<<PHP
|
||||||
<?php
|
<?php
|
||||||
try {
|
try {
|
||||||
|
extract( \$this->using ?? [], \EXTR_OVERWRITE);
|
||||||
extract( \\$class::parseArguments(function($arguments) {}, \$inlineVariables), \EXTR_OVERWRITE);
|
extract( \\$class::parseArguments(function($arguments) {}, \$inlineVariables), \EXTR_OVERWRITE);
|
||||||
|
|
||||||
unset(\$inlineVariables);
|
unset(\$inlineVariables);
|
||||||
}
|
}
|
||||||
catch(\TypeError \$ex) {
|
catch(\TypeError \$ex) {
|
||||||
|
|
||||||
throw new \Exception(
|
throw new \Exception(
|
||||||
sprintf('A block awaiting arguments `%s` instead received `%s` with values `%s`', '$arguments', implode(', ', array_map('gettype', \$inlineVariables)), json_encode(\$inlineVariables))
|
sprintf('A block awaiting arguments `%s` instead received `%s` with values `%s`', '$arguments', implode(', ', array_map('gettype', \$inlineVariables)), json_encode(\$inlineVariables))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -72,7 +71,7 @@ class BlockToken implements ControlStructure {
|
||||||
}
|
}
|
||||||
|
|
||||||
return <<<PHP
|
return <<<PHP
|
||||||
<?php \$___block->slotIsSet($name) || \$___block->setSlot($name, function($definition array \$___using = []) use (\$picea) { extract(\$___using, \EXTR_SKIP); ?>
|
<?php (\$___block ?? \$this)->slotIsSet($name) || \$___block->setSlot($name, function($definition array \$___using = []) use (\$picea) { extract(\$___using, \EXTR_SKIP); ?>
|
||||||
PHP;
|
PHP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,6 +130,9 @@ class BlockToken implements ControlStructure {
|
||||||
elseif ( $value->isVariadic() ) {
|
elseif ( $value->isVariadic() ) {
|
||||||
$parameters[ $value->getName() ] = [];
|
$parameters[ $value->getName() ] = [];
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
$parameters[ $value->getName() ] = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $parameters;
|
return $parameters;
|
||||||
|
|
|
@ -53,7 +53,7 @@ class SectionToken implements ControlStructure {
|
||||||
protected function printEndSection($context) : string
|
protected function printEndSection($context) : string
|
||||||
{
|
{
|
||||||
$section = array_pop($context->sections);
|
$section = array_pop($context->sections);
|
||||||
$build = $context->extendFrom ? "\$___class__template->sectionStack && \$___class__template->renderSection({$section['name']});" : "\$___class__template->renderSection({$section['name']});";
|
$build = $context->extendFrom ? "!empty(\$___class__template->sectionStack) && \$___class__template->renderSection({$section['name']});" : "\$___class__template->renderSection({$section['name']});";
|
||||||
return "<?php array_pop(\$___class__template->sectionStack); }]; $build?>";
|
return "<?php array_pop(\$___class__template->sectionStack); }]; $build?>";
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue