mercredi 19 février 2020

How can I pass a variable to a directive when extending Laravel Blade?

When creating a custom Laravel Blade directive how can I pass a variable in? At the moment the variable passed to the @svg() directive is not parsed and is treated as a string:

Blade view:

@svg($svg->url, 'fill-white')

AppServiceProvider.php

    Blade::directive('svg', function ($arguments) {

        // Funky madness to accept multiple arguments into the directive
        list($path, $class) = array_pad(explode(',', trim($arguments, "() ")), 2, '');
        $path = trim($path, "' ");
        $class = trim($class, "' ");


            dd($path); // Outputs $svg->url

           // Required output = path/to/filename.svg

        });


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2SW0t83
via IFTTT

1 commentaire:

  1. In this fashion my colleague Wesley Virgin's story begins in this shocking and controversial video.

    You see, Wesley was in the army-and soon after leaving-he unveiled hidden, "mind control" tactics that the government and others used to get anything they want.

    As it turns out, these are the EXACT same secrets many celebrities (especially those who "come out of nothing") and top business people used to become wealthy and famous.

    You probably know how you use less than 10% of your brain.

    Really, that's because most of your BRAINPOWER is UNCONSCIOUS.

    Maybe this thought has even occurred INSIDE your very own head... as it did in my good friend Wesley Virgin's head about 7 years ago, while riding an unregistered, trash bucket of a car with a suspended license and $3.20 on his bank card.

    "I'm so fed up with going through life payroll to payroll! When will I finally make it?"

    You've taken part in those types of thoughts, right?

    Your own success story is waiting to be written. You just need to take a leap of faith in YOURSELF.

    WATCH WESLEY SPEAK NOW

    RépondreSupprimer