forked from josh-taylor/sage-svg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsage-svg.php
35 lines (29 loc) · 881 Bytes
/
sage-svg.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
namespace SageSvg;
use function App\sage;
use BladeSvg\SvgFactory;
function registerBinding()
{
if (function_exists('\\App\\sage')) {
sage()->singleton(SvgFactory::class, function () {
$config = [
'inline' => true,
'class' => 'icon',
'svg_path' => get_stylesheet_directory().'/assets/icons/',
];
return new SvgFactory($config);
});
}
}
function registerBladeTag()
{
if (function_exists('\\App\\sage')) {
sage('blade')->compiler()->directive('svg', function ($expression) {
return "<?php echo e(\\App\\sage(\\BladeSvg\\SvgFactory::class)->svg($expression)) ?>";
});
}
}
if (function_exists('add_action')) {
add_action('init', __NAMESPACE__.'\registerBinding');
add_action('init', __NAMESPACE__.'\registerBladeTag');
}