Use array_map() for blade hierarchy loop

This commit is contained in:
QWp6t
2016-12-04 11:21:45 -08:00
parent 7367225c3e
commit f23477386d

View File

@@ -2,8 +2,6 @@
namespace App;
use Roots\Sage\Template;
use Roots\Sage\Template\Wrapper;
use Illuminate\Container\Container;
use Illuminate\Filesystem\Filesystem;
use Roots\Sage\Template\ViewServiceProvider;
@@ -37,15 +35,14 @@ add_filter('excerpt_more', function () {
/**
* Use Blade template engine
*/
foreach (['index', '404', 'archive', 'author', 'category', 'tag', 'taxonomy', 'date', 'home', 'front_page',
'page', 'paged', 'search', 'single', 'singular', 'attachment'] as $type) {
add_filter("{$type}_template_hierarchy", function ($templates) {
foreach ($templates as $template) {
$templates[] = str_replace('.php', '.blade.php', $template);
}
return $templates;
array_map(function ($tag) {
add_filter("{$tag}_template_hierarchy", function($templates) {
return array_merge(str_replace('.php', '.blade.php', $templates), $templates);
});
}
}, [
'index', '404', 'archive', 'author', 'category', 'tag', 'taxonomy', 'date', 'home',
'front_page', 'page', 'paged', 'search', 'single', 'singular', 'attachment'
]);
add_filter('template_include', function ($template) {
$blade_template = (!strpos($template, '.blade.php')) ? str_replace('.php', '.blade.php', $template) : $template;
$blade_template = locate_template(basename($blade_template));