如何在 Laravel 中包含动态内容

How to have dynamic include in Laravel

我有一组 html 代码存在于不同的 blade 文件中,我试图用 foreach 循环添加这些代码,但是 blade 模板无法连接以下文件是我的代码:

@foreach($getplugin as $renderer)

    @include('themes.'$template->theme->name'.Plugins.'$plugins->find($renderer)->type'.'$plugins->find($renderer)->id)

@endforeach

我收到以下错误:

Parse error: syntax error, unexpected '$template' (T_VARIABLE), expecting ',' or ')' (View: C:\wamp\www\NitsEditor\resources\views\nitseditor\test.blade.php)

请帮忙解决这个问题。谢谢

您正在尝试连接字符串,但忘记为连接添加点。

而不是 'themes.'$template 应该是 'themes.'.$template,依此类推。你似乎错过了所有这些。