Skip to content
Advertisement

Laravel Blade compileString gives me a Blank Page

I tried to create a new blade directive in my AppServiceProvider:

<?php
public function boot()
{
  Blade::directive('test', function () {
    return Blade::compileString('@if(1==1) test @endif');
  });
}

And then call this directive in my view:

@test()

But it’s not work and gives me a blank page.

Advertisement

Answer

i try several things but finally i fix this by copy and paste blade directive code from BladeCompiler.php to my custom directive instead of using compileString

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement