Skip to content

Instantly share code, notes, and snippets.

@deyvisonrocha
Last active August 2, 2016 20:20
Show Gist options
  • Save deyvisonrocha/ac307aef402fb6bed40e to your computer and use it in GitHub Desktop.
Save deyvisonrocha/ac307aef402fb6bed40e to your computer and use it in GitHub Desktop.
Create a extend command on Blade for Laravel 4.
<?php
/*
|--------------------------------------------------------------------------
| Extend blade so we can define a variable
| <code>
| @define $variable = "whatever"
| </code>
|--------------------------------------------------------------------------
*/
Blade::extend(function($value) {
return preg_replace('/\@define(.+)/', '<?php ${1}; ?>', $value);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment