From dca85764d2546ec62749aa3157d324c0d1cb2bdf Mon Sep 17 00:00:00 2001 From: David Grudl Date: Thu, 16 May 2024 18:31:19 +0200 Subject: [PATCH] coreParentFinder is called only for main template (BC break) --- src/Latte/Runtime/Template.php | 2 +- tests/common/Template.getParentName().phpt | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) 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();