Skip to content

Instantly share code, notes, and snippets.

@martinbean
Last active October 26, 2016 11:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinbean/cb70ff58c8ef36224e533a1da91a47d5 to your computer and use it in GitHub Desktop.
Save martinbean/cb70ff58c8ef36224e533a1da91a47d5 to your computer and use it in GitHub Desktop.
Laravel Blade directive for FontAwesome icons.
<?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, "'"));
});
}
}
@martinbean
Copy link
Author

Usage: @fa('chevron-left')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment