Skip to content

Commit

Permalink
v1.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Log1x committed Aug 23, 2017
1 parent 331edd9 commit e764ca0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 28 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ add_filter('bladesvg_sprite_prefix', function () {
```
<ul>
<li>@svg('phone')</li>
<li>{{ svg_image('phone-alt') }}</li>
<li>{{ \BladeSvgSage\svg_image('phone-alt') }}</li>
</ul>
```

Expand Down
20 changes: 4 additions & 16 deletions src/blade-svg-sage.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
<?php
/*
Plugin Name: Blade SVG for Sage
Plugin URI: http://github.com/log1x/blade-svg-sage
Description: Simple package to add Blade SVG to Sage 9
Version: 1.0.5
Author: Log1x
Author URI: https://log1x.com
License: MIT License
License URI: http://opensource.org/licenses/MIT
GitHub Plugin URI: log1x/blade-svg-sage
GitHub Branch: master
*/


namespace BladeSvgSage;

use function App\sage;
Expand All @@ -25,7 +13,7 @@
}

/**
* Initialize the plugin
* Initialize SvgFactory
*/
function init()
{
Expand All @@ -51,11 +39,11 @@ function directive()
{
if (function_exists('\App\sage')) {
sage('blade')->compiler()->directive('icon', function ($expression) {
return "<?php echo e(svg_image($expression)) ?>";
return "<?php echo e(\BladeSvgSage\svg_image($expression)) ?>";
});

sage('blade')->compiler()->directive('svg', function ($expression) {
return "<?php echo e(svg_image($expression)) ?>";
return "<?php echo e(\BladeSvgSage\svg_image($expression)) ?>";
});
}
}
Expand Down
36 changes: 25 additions & 11 deletions src/helpers.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
<?php

if (!function_exists('get_dist_path')) {
function get_dist_path($path)
{
return trailingslashit(\App\config('theme.dir')) . trailingslashit('dist') . $path;
}
namespace BladeSvgSage;

use function App\sage;
use function App\config;

/**
* Get Sage's dist path
*
* @param string $path
* @return string
*/
function get_dist_path($path)
{
return trailingslashit(config('theme.dir')) . trailingslashit('dist') . $path;
}

if (!function_exists('svg_image')) {
function svg_image($icon, $class = '', $attrs = [])
{
return wp_die('test');
return \App\sage(\BladeSvg\SvgFactory::class)->svg(\App\sage('assets')->get($icon), $class, $attrs);
}
/**
* Simple helper for our directive.
*
* @param string $icon
* @param string $class
* @param array $attrs
* @return mixed
*/
function svg_image($icon, $class = '', $attrs = [])
{
return sage(\BladeSvg\SvgFactory::class)->svg(sage('assets')->get($icon), $class, $attrs);
}

0 comments on commit e764ca0

Please sign in to comment.