Created
June 11, 2015 11:22
-
-
Save CupOfTea696/bc9a911039b9c012f62c to your computer and use it in GitHub Desktop.
Laravel Blade @define directive
This file contains hidden or 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 namespace Stribe\Providers; | |
| use Blade; | |
| use Illuminate\Support\ServiceProvider; | |
| class AppServiceProvider extends ServiceProvider { | |
| /** | |
| * Bootstrap any application services. | |
| * | |
| * @return void | |
| */ | |
| public function boot() | |
| { | |
| Blade::directive('define', function($expression) { | |
| $expression = preg_replace('/\\(([^,]+),(?:\\s)+?([^\\)]+)\\)/', '[$1 => $2]', $expression); | |
| return "<?php extract({$expression}, EXTR_OVERWRITE); ?>"; | |
| }); | |
| } | |
| /** | |
| * Register any application services. | |
| * | |
| * This service provider is a great spot to register your various container | |
| * bindings with the application. As you can see, we are registering our | |
| * "Registrar" implementation here. You can add your own bindings too! | |
| * | |
| * @return void | |
| */ | |
| public function register() | |
| { | |
| // | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment