Skip to content

Commit 962bde9

Browse files
committed
if no layout then ignoring that part
1 parent fa86b2a commit 962bde9

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/Console/CompileBlades.php

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,14 @@
55
use Illuminate\Console\Command;
66
use Illuminate\Foundation\Inspiring;
77

8-
/**
9-
* Class CompileBlades
10-
* @package Techo\CompileBlades\Console\Commands
11-
*/
128
class CompileBlades extends Command
139
{
1410
/**
1511
* The name and signature of the console command.
1612
*
1713
* @var string
1814
*/
19-
protected $signature = 'compile:blades {blade-name}';
15+
protected $signature = 'compile:blades {blade-name}';
2016

2117
/**
2218
* The console command description.
@@ -79,7 +75,8 @@ private function implodeIncludes(&$blade)
7975
// Include files and append variables
8076
foreach ($includesWithVariables as $subViewName => $arrayOfVariables) {
8177
$subView = $arrayOfVariables . "\r\n" . file_get_contents(view($subViewName)->getPath());
82-
$blade = preg_replace("/@include.*?['|\"]" . $subViewName . "['|\"]((,)(.*?))?[)]$/im", $subView, $blade);
78+
$blade =
79+
preg_replace("/@include.*?['|\"]" . $subViewName . "['|\"]((,)(.*?))?[)]$/im", $subView, $blade);
8380
}
8481
preg_match_all("/@include.*?['|\"](.*?)['|\"]((,)(.*?))?[)]$/sim", $blade, $pregOutput);
8582
if (++$i > 2) {
@@ -115,12 +112,14 @@ private function replaceLayout(&$blade)
115112

116113
//find the extended file
117114
preg_match_all('/@extends[(][\'](.*?)[\'][)]/si', $blade, $output);
118-
$layout = $output[1][0];
119-
//take out the extend keyword
120-
$blade = preg_replace('/@extends[(][\'](.*?)[\'][)]/si', "{{-- Extend layout was here --}}", $blade);
121-
//bring the layout
122-
$layout = file_get_contents(view($layout)->getPath());
123-
$blade = $blade . " " . $layout;
115+
if (!empty($output[1])) {
116+
$layout = $output[1][0];
117+
//take out the extend keyword
118+
$blade = preg_replace('/@extends[(][\'](.*?)[\'][)]/si', "{{-- Extend layout was here --}}", $blade);
119+
//bring the layout
120+
$layout = file_get_contents(view($layout)->getPath());
121+
$blade = $blade . " " . $layout;
122+
}
124123

125124
return $layout;
126125
}

0 commit comments

Comments
 (0)