Last active
August 29, 2015 14:21
-
-
Save sniper7kills/56b48d339f413050d3b0 to your computer and use it in GitHub Desktop.
Simple Blade Extention to render a blade into a single line. Usefull for appending a view using Javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Blade::extend(function($view, $compiler) { | |
$pattern = $compiler->createOpenMatcher('oneLine'); | |
$page="Default"; | |
if (preg_match_all($pattern, $view,$result)){ | |
foreach($result[2] as $match){ | |
$param = trim(trim($match, '(\'\')')); | |
$page = View::make($param)->render(); | |
$page = implode(" ", explode("\n", $page)); | |
$view = preg_replace($pattern, $page, $view); | |
} | |
} | |
return $view; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Still under Development