Nesting views with laravel Blade

Solution:1

You can do this

@section('nav')
  @include('another')
  @include('magical')
  @include('snippet')
@end

Solution:2

Another solution, in case you were wishing to dynamically load different subviews, you can nest using the View Class. E.g. you could have the following in a Route / Controller:

return View::make('home')->nest('subnav','home/nav', array('some' => 'data'); 

and then in your home.blade.php, you could do this:

@extends('layout')

@section('nav')
<p>NAVIGATION</p>
{{ $subnav }}
@end

@section('content')
<p>HELLO WORLD!</p>
@end

This can be done with an include and a variable as well (@include($viewname, array('some' => 'data')) however I’d say its cleaner as it removes the logic from the view, particularly if your nested views aren’t always the same blade file.