I want to use a partial view with content from another partial view, something like this:

@include('view1', array('content' => @include('view2')))

Unfortunately the view2is rendered as expected but view1is not, and just outputs @includein plain text.

The 2 views are not related at all therefore I believe I cannot use @yield (as this will mean a view will have to extend another).

有帮助吗?

解决方案

Assuming that the inclusion of both views aren't dynamic, when returning the master view (the one that contains the include), you can nest view2

return View::make('master')->nest('content', 'view2');

Then in the view

@include('view1', array('content' => $content))

That or you could just include view2 within view1, is there a specific reason that this needs to be in the master view?

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top