|
5 | 5 | use Illuminate\Console\Command; |
6 | 6 | use Illuminate\Foundation\Inspiring; |
7 | 7 |
|
8 | | -/** |
9 | | - * Class CompileBlades |
10 | | - * @package Techo\CompileBlades\Console\Commands |
11 | | - */ |
12 | 8 | class CompileBlades extends Command |
13 | 9 | { |
14 | 10 | /** |
15 | 11 | * The name and signature of the console command. |
16 | 12 | * |
17 | 13 | * @var string |
18 | 14 | */ |
19 | | - protected $signature = 'compile:blades {blade-name}'; |
| 15 | + protected $signature = 'compile:blades {blade-name}'; |
20 | 16 |
|
21 | 17 | /** |
22 | 18 | * The console command description. |
@@ -79,7 +75,8 @@ private function implodeIncludes(&$blade) |
79 | 75 | // Include files and append variables |
80 | 76 | foreach ($includesWithVariables as $subViewName => $arrayOfVariables) { |
81 | 77 | $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); |
83 | 80 | } |
84 | 81 | preg_match_all("/@include.*?['|\"](.*?)['|\"]((,)(.*?))?[)]$/sim", $blade, $pregOutput); |
85 | 82 | if (++$i > 2) { |
@@ -115,12 +112,14 @@ private function replaceLayout(&$blade) |
115 | 112 |
|
116 | 113 | //find the extended file |
117 | 114 | 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 | + } |
124 | 123 |
|
125 | 124 | return $layout; |
126 | 125 | } |
|
0 commit comments