Skip to content

Commit cdf59b0

Browse files
committed
UIExtension: {layout auto} skips finder in referring templates to prevent recursion
1 parent 74bdad0 commit cdf59b0

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

src/Bridges/ApplicationLatte/UIExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public static function createExtendsNode(Tag $tag): ExtendsNode
132132
$auto = $tag->parser->stream->is('auto');
133133
$node = ExtendsNode::create($tag);
134134
if ($auto) {
135-
$node->extends = new AuxiliaryNode(fn() => '$this->global->uiPresenter->findLayoutTemplateFile()');
135+
$node->extends = new AuxiliaryNode(fn() => '($this->getReferringTemplate() ? null : $this->global->uiPresenter->findLayoutTemplateFile())');
136136
}
137137
return $node;
138138
}

tests/Bridges.Latte3/Template.getParentName().phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,10 @@ Assert::exception(
7171
Assert::same('layout.latte', $template->getParentName());
7272

7373

74+
// {extends auto} skips the finder in referring templates to prevent recursion
7475
$latte->setLoader(new Latte\Loaders\StringLoader([
7576
'main.latte' => '{extends foo.latte}',
7677
'foo.latte' => '{extends auto}',
7778
'layout.latte' => 'layout',
7879
]));
79-
Assert::same('layout', $template = $latte->renderToString('main.latte'));
80+
Assert::same('', $template = $latte->renderToString('main.latte'));

0 commit comments

Comments
 (0)