Skip to content

Instantly share code, notes, and snippets.

@wouldhide
Last active May 4, 2016 10:07
Show Gist options
  • Save wouldhide/09039580076e53b04dd7a9eb85d37b59 to your computer and use it in GitHub Desktop.
Save wouldhide/09039580076e53b04dd7a9eb85d37b59 to your computer and use it in GitHub Desktop.
// put snippet in app/Providers/AppServiceProvider boot method
Blade::extend(function ($value, $compiler) {
$value = preg_replace('/(?<=\s)@switch\((.*)\)(\s*)@case\((.*)\)(?=\s)/', '<?php switch($1):$2case $3: ?>', $value);
$value = preg_replace('/(?<=\s)@endswitch(?=\s)/', '<?php endswitch; ?>', $value);
$value = preg_replace('/(?<=\s)@case\((.*)\)(?=\s)/', '<?php case $1: ?>', $value);
$value = preg_replace('/(?<=\s)@default(?=\s)/', '<?php default: ?>', $value);
$value = preg_replace('/(?<=\s)@break(?=\s)/', '<?php break; ?>', $value);
return $value;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment