srph
srph

Reputation: 1322

Using a Blade directive in a Blade directive

I'm using Laravel 5.1. I am trying to use a Blade directive (@extend) with my custom Blade directive.

Blade::directive('base', function() use ($theme) {
  return "@extends($theme)"
});

However, the above code only literally displays the contents (@extends($theme))

Upvotes: 6

Views: 3027

Answers (1)

David Barker
David Barker

Reputation: 14620

Contrary to a comment I made earlier, I think this is possible (but untested) using the blade compiler.

Blade::directive('base', function() use ($theme) {
    return Blade::compileString("@extends({$theme})");
});

Upvotes: 6

Related Questions