diff --git a/src/Application/UI/Presenter.php b/src/Application/UI/Presenter.php index 637e9d07e..e44bce7de 100644 --- a/src/Application/UI/Presenter.php +++ b/src/Application/UI/Presenter.php @@ -504,14 +504,14 @@ public function formatLayoutTemplateFiles() $layout = $this->layout ? $this->layout : 'layout'; $rc = $this->getReflection(); $dir = dirname($rc->getFileName()); - $dir = is_dir("$dir/templates") ? $dir : dirname($dir); + $dir = ($newWay = is_dir("$dir/templates")) ? $dir : dirname($dir); $list = [ "$dir/templates/$presenter/@$layout.latte", "$dir/templates/$presenter.@$layout.latte", ]; do { $list[] = "$dir/templates/@$layout.latte"; - $dir = dirname($dir); + $dir = $newWay ? FALSE : dirname($dir); } while ($dir && ($name = substr($name, 0, strrpos($name, ':')))); while (($rc = $rc->getParentClass()) && $rc->getName() !== __CLASS__) { diff --git a/tests/Application.templates/Presenter.formatLayoutTemplateFiles.phpt b/tests/Application.templates/Presenter.formatLayoutTemplateFiles.phpt index 146fdd377..212cf9145 100644 --- a/tests/Application.templates/Presenter.formatLayoutTemplateFiles.phpt +++ b/tests/Application.templates/Presenter.formatLayoutTemplateFiles.phpt @@ -47,8 +47,6 @@ test(function() { // with module & subdir templates __DIR__ . DIRECTORY_SEPARATOR . 'one/templates/One/@layout.latte', __DIR__ . DIRECTORY_SEPARATOR . 'one/templates/One.@layout.latte', __DIR__ . DIRECTORY_SEPARATOR . 'one/templates/@layout.latte', - __DIR__ . '/templates/@layout.latte', - dirname(__DIR__) . '/templates/@layout.latte', ], $presenter->formatLayoutTemplateFiles() ); });