diff --git a/src/Latte/Runtime/Template.php b/src/Latte/Runtime/Template.php index abe04cd5a..dfe9ce54a 100644 --- a/src/Latte/Runtime/Template.php +++ b/src/Latte/Runtime/Template.php @@ -138,7 +138,7 @@ public function render(?string $block = null): void $params = $this->prepare(); - if ($this->parentName === null && isset($this->global->coreParentFinder)) { + if ($this->parentName === null && !$this->referringTemplate && isset($this->global->coreParentFinder)) { $this->parentName = ($this->global->coreParentFinder)($this); } diff --git a/tests/common/Template.getParentName().phpt b/tests/common/Template.getParentName().phpt index 114291d84..efd2b234a 100644 --- a/tests/common/Template.getParentName().phpt +++ b/tests/common/Template.getParentName().phpt @@ -48,11 +48,7 @@ $latte->setLoader(new Latte\Loaders\StringLoader([ 'extendsNone' => '{extends none}', 'parent' => '', ])); -$latte->addProvider('coreParentFinder', function ($template) { - if (!$template->getReferenceType()) { - return 'parent'; - } -}); +$latte->addProvider('coreParentFinder', fn($template) => 'parent'); $template = $latte->createTemplate('empty'); $template->render();