Log1x / blade-svg-sage

A simple package to add support for Blade SVG by Adam Wathan to Roots Sage.
MIT License
73 stars 13 forks source link

Installing package has no effect #22

Closed issunboshi closed 5 years ago

issunboshi commented 5 years ago

Hi,

I've installed the package but when calling @svg('icon-name') from a view e.g. in one of my partials I have @svg('facebook') the template just renders the text "@svg('facebook')".

I've added the filter to Sage's setup.php

add_filter('bladesvg', function () {
    return [
        'svg_path' => 'resources/svg',
        'inline' => true,
        'class' => 'svg svg-icon'
    ];
});

and the icons exist at that path relative to the sage root.

Here are the 2 ways I've tried to use it so far

<li class="social-icons__item"><a href="{!! esc_url($social_icons['facebook']) !!}" class="social-icons__link">Facebook @svg('facebook')</a></li>

and

<li class="social-icons__item"><a href="{!! esc_url($social_icons['facebook']) !!}" class="social-icons__link">Facebook {{ svg_image('facebook') }}</a></li>

The first does as I've mentioned above and the second causes Call to undefined function app().

Sage version "roots/sage-lib": "9.0.9"

catgofire commented 5 years ago

For your second example you need to call it within the App namespace:

Facebook {{ \App\svg_image('facebook') }}

Try deleting your views cache (uploads/cache/), your composer cache (theme_dir/.cache-loader), and running (from theme_dir) composer dump-autoload

Log1x commented 5 years ago

^

issunboshi commented 5 years ago

Thanks, would that also apply to @svg('facebook'), so @\App\svg('facebook')?

Log1x commented 5 years ago

No. If @svg() still isn't working, it would usually come down to a cache issue.

catgofire commented 5 years ago

@issunboshi Blade directives (things following @) will never have special characters like \ in the name