Skip to content

Commit e15c4d2

Browse files
committed
Presenter::formatTemplateFiles() returns "template/<view>.latte" for local 'template' folder (BC break)
1 parent 81a1a34 commit e15c4d2

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/Application/UI/Presenter.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,11 +524,12 @@ public function formatTemplateFiles()
524524
{
525525
$name = $this->getName();
526526
$presenter = substr($name, strrpos(':' . $name, ':'));
527-
$dir = dirname($this->getReflection()->getFileName());
528-
$dir = is_dir("$dir/templates") ? $dir : dirname($dir);
527+
$presenterDir = dirname($this->getReflection()->getFileName());
528+
$dir = is_dir("$presenterDir/templates") ? $presenterDir : dirname($presenterDir);
529529
return [
530530
"$dir/templates/$presenter/$this->view.latte",
531531
"$dir/templates/$presenter.$this->view.latte",
532+
"$presenterDir/templates/$this->view.latte",
532533
];
533534
}
534535

tests/Application.templates/Presenter.formatTemplateFiles.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ test(function() { // with subdir templates
2121
Assert::same( [
2222
__DIR__ . DIRECTORY_SEPARATOR . 'one/templates/One/view.latte',
2323
__DIR__ . DIRECTORY_SEPARATOR . 'one/templates/One.view.latte',
24+
__DIR__ . DIRECTORY_SEPARATOR . 'one/templates/view.latte',
2425
], $presenter->formatTemplateFiles() );
2526
});
2627

@@ -33,6 +34,7 @@ test(function() { // without subdir templates
3334
Assert::same( [
3435
__DIR__ . '/templates/Two/view.latte',
3536
__DIR__ . '/templates/Two.view.latte',
37+
__DIR__ . DIRECTORY_SEPARATOR . 'two/templates/view.latte',
3638
], $presenter->formatTemplateFiles() );
3739
});
3840

@@ -45,6 +47,7 @@ test(function() { // with module & subdir templates
4547
Assert::same( [
4648
__DIR__ . DIRECTORY_SEPARATOR . 'one/templates/One/view.latte',
4749
__DIR__ . DIRECTORY_SEPARATOR . 'one/templates/One.view.latte',
50+
__DIR__ . DIRECTORY_SEPARATOR . 'one/templates/view.latte',
4851
], $presenter->formatTemplateFiles() );
4952
});
5053

@@ -57,5 +60,6 @@ test(function() { // with module & without subdir templates
5760
Assert::same( [
5861
__DIR__ . '/templates/Two/view.latte',
5962
__DIR__ . '/templates/Two.view.latte',
63+
__DIR__ . DIRECTORY_SEPARATOR . 'two/templates/view.latte',
6064
], $presenter->formatTemplateFiles() );
6165
});

0 commit comments

Comments
 (0)