Last active
August 29, 2015 14:10
-
-
Save mrkmg/ddc183f3ce881d9fb636 to your computer and use it in GitHub Desktop.
Adds @asset, @assetjs, @assetcss to blade templates
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
<?php | |
// Adds @asset tag to blade templates; | |
// USAGE: @asset('path/to/file.css|js') | |
Blade::extend(function($view, \Illuminate\View\Compilers\BladeCompiler $compiler) | |
{ | |
$pattern = $compiler->createMatcher('asset'); | |
return preg_replace($pattern, '<?php Assets::add$2; ?>', $view); | |
}); | |
// Adds @assetjs tag to blade templates; | |
// USAGE: @assetjs('path/to/file.js') | |
Blade::extend(function($view, \Illuminate\View\Compilers\BladeCompiler $compiler) | |
{ | |
$pattern = $compiler->createMatcher('assetjs'); | |
return preg_replace($pattern, '<?php Assets::addJs$2; ?>', $view); | |
}); | |
// Adds @assetcss tag to blade templates; | |
// USAGE: @assetcss('path/to/file.css') | |
Blade::extend(function($view, \Illuminate\View\Compilers\BladeCompiler $compiler) | |
{ | |
$pattern = $compiler->createMatcher('assetcss'); | |
return preg_replace($pattern, '<?php Assets::addCss$2; ?>', $view); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment