Skip to content

Commit

Permalink
Presenter: support for direct setting layout file
Browse files Browse the repository at this point in the history
  • Loading branch information
horacekp authored and dg committed Apr 30, 2016
1 parent b12c478 commit 8e388e3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Application/UI/Presenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,9 @@ public function findLayoutTemplateFile()
*/
public function formatLayoutTemplateFiles()
{
if (preg_match('#/|\\\\#', $this->layout)) {
return [$this->layout];
}
list($module, $presenter) = Helpers::splitName($this->getName());
$layout = $this->layout ? $this->layout : 'layout';
$dir = dirname($this->getReflection()->getFileName());
Expand Down
10 changes: 10 additions & 0 deletions tests/UI/Presenter.formatLayoutTemplateFiles.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,13 @@ test(function () { // with module & without subdir templates
dirname(dirname(__DIR__)) . '/templates/@layout.latte',
], $presenter->formatLayoutTemplateFiles());
});


test(function () { // direct file
$presenter = new Presenter2;
$presenter->setLayout(__DIR__ . '/file.latte');

Assert::same([
__DIR__ . '/file.latte'
], $presenter->formatLayoutTemplateFiles());
});

0 comments on commit 8e388e3

Please sign in to comment.