Skip to content

Commit

Permalink
if no layout then ignoring that part
Browse files Browse the repository at this point in the history
  • Loading branch information
abidulrmdn committed Jul 2, 2017
1 parent fa86b2a commit 962bde9
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/Console/CompileBlades.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,14 @@
use Illuminate\Console\Command;
use Illuminate\Foundation\Inspiring;

/**
* Class CompileBlades
* @package Techo\CompileBlades\Console\Commands
*/
class CompileBlades extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'compile:blades {blade-name}';
protected $signature = 'compile:blades {blade-name}';

/**
* The console command description.
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 962bde9

Please sign in to comment.