Last active
October 26, 2016 11:32
-
-
Save martinbean/cb70ff58c8ef36224e533a1da91a47d5 to your computer and use it in GitHub Desktop.
Laravel Blade directive for FontAwesome icons.
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 | |
namespace App\Providers; | |
use Illuminate\Support\Facades\Blade; | |
use Illuminate\Support\ServiceProvider; | |
class BladeServiceProvider extends ServiceProvider | |
{ | |
/** | |
* Bootstrap the application services. | |
* | |
* @return void | |
*/ | |
public function boot() | |
{ | |
Blade::directive('fa', function ($expression) { | |
return sprintf('<span aria-hidden="true" class="fa fa-fw fa-%s"></span>', trim($expression, "'")); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
@fa('chevron-left')