Using a Blade directive in a Blade directive

随声附和 提交于 2019-12-23 09:17:33

问题


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))


回答1:


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})");
});


来源:https://stackoverflow.com/questions/30968498/using-a-blade-directive-in-a-blade-directive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!