Skip to content

Instantly share code, notes, and snippets.

@nboliver
Forked from troymcginnis/directives.php
Created May 16, 2018 18:16
Show Gist options
  • Save nboliver/fd48e5b0703f55a592b8d1ea85111895 to your computer and use it in GitHub Desktop.
Save nboliver/fd48e5b0703f55a592b8d1ea85111895 to your computer and use it in GitHub Desktop.
<?php
namespace App;
/**
* Custom Blade directives
*/
add_action('after_setup_theme', function () {
/**
* Icon Blade directives
*/
sage('blade')->compiler()->directive('icon', function ($id) {
if($id){
return '<svg class="icon icon--' . $id . '"><use xlink:href="' . asset_path("images/symbols.svg") . '#icon-' . $id . '"></use></svg>';
}
});
}
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@icon('facebook')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment