Laravel blade custom directive with include partial
If anyone comes across this question since its post in '16, Laravel now has a blade helper to create a custom include
directive (since version 5.6.5):
Blade::include('viewsNameSpace::path.to.view.file');
This is to be added to the boot()
method of your app service provider. More examples here.
This is how I made it work:
return "<?php echo view('$formPartial')->render(); ?>";
Where $formPartial
is 'viewsNameSpace::partials._form'
.