Closed richstandbrook closed 2 years ago
Actually, this is the working principle of blade directives. See same issue: https://stackoverflow.com/questions/41003733/pass-multiple-parameters-to-a-blade-directive
I know there is a problem with my directives, but you can use it like this:
@test(baz, quaz)
'afbora.blade.directives' => [
'test' => function ($params) {
list($foo, $bar) = explode(',', $params);
return "bar:($bar) foo:($foo)";
}
],
Ahh I see yes. I had started to dig through the Blade code. Thanks, that makes sense
I've tried defining a custom directive in the config file, however the closure only ever receives one argument.
Usage:
This results in the error:
If I make the second argument optional
function ($foo, $bar = null)
then I get this output:You see the second $bar properly is empty and $foo contains the string
'baz', 'quaz'