Skip to content

Commit

Permalink
coreParentFinder is called only for main template (BC break)
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed May 16, 2024
1 parent 4762049 commit fe4ca62
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Latte/Runtime/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
6 changes: 1 addition & 5 deletions tests/common/Template.getParentName().phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit fe4ca62

Please sign in to comment.