Ensure to get templates filenames without path and extension.
This commit is contained in:
@@ -81,12 +81,25 @@ function asset_path($asset)
|
|||||||
*/
|
*/
|
||||||
function filter_templates($templates)
|
function filter_templates($templates)
|
||||||
{
|
{
|
||||||
|
$paths = apply_filters('sage/filter_templates/paths', [
|
||||||
|
'views',
|
||||||
|
'resources/views'
|
||||||
|
]);
|
||||||
|
$paths_pattern = "#^(" . implode('|', $paths) . ")/#";
|
||||||
|
|
||||||
return collect($templates)
|
return collect($templates)
|
||||||
->map(function ($template) {
|
->map(function ($template) use ($paths_pattern) {
|
||||||
return preg_replace('#\.(blade\.)?php$#', '', ltrim($template));
|
/** Remove .blade.php/.blade/.php from template names */
|
||||||
|
$template = preg_replace('#\.(blade\.?)?(php)?$#', '', ltrim($template));
|
||||||
|
|
||||||
|
/** Remove partial $paths from the beginning of template names */
|
||||||
|
if (strpos($template, '/')) {
|
||||||
|
$template = preg_replace($paths_pattern, '', $template);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $template;
|
||||||
})
|
})
|
||||||
->flatMap(function ($template) {
|
->flatMap(function ($template) use ($paths) {
|
||||||
$paths = apply_filters('sage/filter_templates/paths', ['views', 'resources/views']);
|
|
||||||
return collect($paths)
|
return collect($paths)
|
||||||
->flatMap(function ($path) use ($template) {
|
->flatMap(function ($path) use ($template) {
|
||||||
return [
|
return [
|
||||||
|
|||||||
Reference in New Issue
Block a user