I have a custom Blade directive from which I'm trying to include a partial with the Blade syntax @include(). The problem is that I have a custom views namespace:
\Blade::directive('name', function() {
$viewsNamespace = 'viewsNameSpace::';
$formPartial = $viewsNamespace . 'partials._form';
return "{{ @include({$formPartial}) }}";
});
This outputs the error,
Class 'viewsNameSpace' not found
because its interpreting viewsNameSpace:: as a class.
This outputs just the string without parsing it:
return "@include('{$formPartial}')";
And this is not throwing any errors but its not loading the partial:
return "{{ @include('{$formPartial}') }}";
Please note that the partial is working when I'm using in in a template like this:
@include('viewsNameSpace::partials._form')
but I can't make it work from the directive.
Any help and suggestions would be appreciated! Thank you!