diff --git a/src/filters.php b/src/filters.php index 11894a9..dd6ae49 100644 --- a/src/filters.php +++ b/src/filters.php @@ -31,9 +31,12 @@ add_filter('excerpt_more', function () { /** * Template Hierarchy should search for .blade.php files */ -array_map(function ($tag) { - add_filter("{$tag}_template_hierarchy", function ($templates) { - return array_merge(str_replace('.php', '.blade.php', $templates), $templates); +array_map(function ($type) { + add_filter("{$type}_template_hierarchy", function ($templates) { + return call_user_func_array('array_merge', array_map(function ($template) { + $normalizedTemplate = str_replace('.', '/', sage('blade')->normalizeViewPath($template)); + return ["{$normalizedTemplate}.blade.php", "{$normalizedTemplate}.php"]; + }, $templates)); }); }, [ 'index', '404', 'archive', 'author', 'category', 'tag', 'taxonomy', 'date', 'home', diff --git a/src/lib/Sage/Template/BladeProvider.php b/src/lib/Sage/Template/BladeProvider.php index 9fa89d2..02751d7 100644 --- a/src/lib/Sage/Template/BladeProvider.php +++ b/src/lib/Sage/Template/BladeProvider.php @@ -23,7 +23,7 @@ class BladeProvider extends Blade */ public function __construct($viewPaths, $cachePath, ContainerContract $container = null) { - parent::__construct($viewPaths, $cachePath, $container); + parent::__construct((array) $viewPaths, $cachePath, $container); $this->registerViewFinder(); } @@ -97,7 +97,8 @@ class BladeProvider extends Blade $view = str_replace('\\', '/', $file); // Remove unnecessary parts of the path - $view = str_replace(array_merge((array) $this->viewPaths, ['.blade.php', '.php']), '', $view); + $remove = array_merge($this->viewPaths, array_map('basename', $this->viewPaths), ['.blade.php', '.php']); + $view = str_replace($remove, '', $view); // Remove leading slashes $view = ltrim($view, '/');