From 962bde9a488ba3287d7b5b71c80182a68fc221ed Mon Sep 17 00:00:00 2001 From: Abidul Wahab Ramadan Date: Sun, 2 Jul 2017 15:20:04 +0800 Subject: [PATCH] if no layout then ignoring that part --- src/Console/CompileBlades.php | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/Console/CompileBlades.php b/src/Console/CompileBlades.php index 35d5cba..6b57095 100755 --- a/src/Console/CompileBlades.php +++ b/src/Console/CompileBlades.php @@ -5,10 +5,6 @@ use Illuminate\Console\Command; use Illuminate\Foundation\Inspiring; -/** - * Class CompileBlades - * @package Techo\CompileBlades\Console\Commands - */ class CompileBlades extends Command { /** @@ -16,7 +12,7 @@ class CompileBlades extends Command * * @var string */ - protected $signature = 'compile:blades {blade-name}'; + protected $signature = 'compile:blades {blade-name}'; /** * The console command description. @@ -79,7 +75,8 @@ private function implodeIncludes(&$blade) // Include files and append variables foreach ($includesWithVariables as $subViewName => $arrayOfVariables) { $subView = $arrayOfVariables . "\r\n" . file_get_contents(view($subViewName)->getPath()); - $blade = preg_replace("/@include.*?['|\"]" . $subViewName . "['|\"]((,)(.*?))?[)]$/im", $subView, $blade); + $blade = + preg_replace("/@include.*?['|\"]" . $subViewName . "['|\"]((,)(.*?))?[)]$/im", $subView, $blade); } preg_match_all("/@include.*?['|\"](.*?)['|\"]((,)(.*?))?[)]$/sim", $blade, $pregOutput); if (++$i > 2) { @@ -115,12 +112,14 @@ private function replaceLayout(&$blade) //find the extended file preg_match_all('/@extends[(][\'](.*?)[\'][)]/si', $blade, $output); - $layout = $output[1][0]; - //take out the extend keyword - $blade = preg_replace('/@extends[(][\'](.*?)[\'][)]/si', "{{-- Extend layout was here --}}", $blade); - //bring the layout - $layout = file_get_contents(view($layout)->getPath()); - $blade = $blade . " " . $layout; + if (!empty($output[1])) { + $layout = $output[1][0]; + //take out the extend keyword + $blade = preg_replace('/@extends[(][\'](.*?)[\'][)]/si', "{{-- Extend layout was here --}}", $blade); + //bring the layout + $layout = file_get_contents(view($layout)->getPath()); + $blade = $blade . " " . $layout; + } return $layout; }