Skip to content

Commit

Permalink
Revisioned Blade Directive
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuadegier committed Nov 11, 2016
1 parent 5e8f3bf commit a06ccce
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions src/LaravelFontAwesomeServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,8 @@ class LaravelFontAwesomeServiceProvider extends ServiceProvider
*/
public function boot()
{
Blade::directive('fa', function ($arguments) {
list($icon, $attributes) = explode(',', str_replace(['(', ')', ' ', "'"], '', $arguments), 2);

$options = [];

if ($attributes != '') {
$rawAttributes = str_replace(['array(', '[', ']', ')'], '', $attributes);
$arrAttributes = explode(',', $rawAttributes);

if (count($arrAttributes) > 0) {
foreach ($arrAttributes as $string) {
$attr = explode('=>', $string);
$options[$attr[0]] = $attr[1];
}
}
}

return (new LaravelFontAwesome())->icon($icon, $options);
Blade::directive('fa', function ($expression) {
return "<?php echo FontAwesome::icon({$expression}); ?>";
});
}

Expand Down

0 comments on commit a06ccce

Please sign in to comment.