我正在尝试在laravel中编写自定义指令.但是,它只返回我的刀片部分的路径作为字符串,而不是像@include那样的实际html.
@customInclude('authenticated/partials/header2')
Blade::directive('customInclude', function($partial){
if(Config::get('constants.ORG_ID') === 'organizationId'){
return "<?php echo $partial; ?>";
}
});
Run Code Online (Sandbox Code Playgroud)
我希望自定义指令返回路径'authenticated/partials/header2'中找到的html,但是,刀片似乎没有意识到路径是我的php中的路径.我的自定义指令存在于AppServiceProvider.php文件btw中.有谁知道@include如何运作得非常好,所以他们可以解释为什么我的路径没有被识别.
很酷的问题,需要一些挖掘,但是你可以很容易地复制 laravel 所做的事情:
Blade::directive('customInclude', function($partial){
if(Config::get('constants.ORG_ID') === 'organizationId'){
return "<?php echo view($partial); ?>";
}
});
Run Code Online (Sandbox Code Playgroud)