Skip to content

Commit aca6b40

Browse files
horacekpdg
authored andcommitted
Presenter: support for direct setting layout file
1 parent be4baf6 commit aca6b40

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/Application/UI/Presenter.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,9 @@ public function findLayoutTemplateFile()
498498
*/
499499
public function formatLayoutTemplateFiles()
500500
{
501+
if (preg_match('#/|\\\\#', $this->layout)) {
502+
return [$this->layout];
503+
}
501504
list($module, $presenter) = Helpers::splitName($this->getName());
502505
$layout = $this->layout ? $this->layout : 'layout';
503506
$dir = dirname($this->getReflection()->getFileName());

tests/UI/Presenter.formatLayoutTemplateFiles.phpt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,13 @@ test(function () { // with module & without subdir templates
6464
dirname(dirname(__DIR__)) . '/templates/@layout.latte',
6565
], $presenter->formatLayoutTemplateFiles());
6666
});
67+
68+
69+
test(function () { // direct file
70+
$presenter = new Presenter2;
71+
$presenter->setLayout(__DIR__ . '/file.latte');
72+
73+
Assert::same([
74+
__DIR__ . '/file.latte'
75+
], $presenter->formatLayoutTemplateFiles());
76+
});

0 commit comments

Comments
 (0)