laravel的blade模板的布局嵌套

测试路由

Route::get('/', function()
{
    $value = [1,2,3];
    return view('home.index', array('data' => $value));
});

 

views下面的目录结构

/Applications/MAMP/htdocs/testApp/resources/views
mac:views mmc$ tree
.

├── home
│   └── index.blade.php
├── mylayout
│   └── test_layout.blade.php

 

index.blade.php

@extends('mylayout.test_layout')

@section('aaa')

<?php
dd($data);
foreach($data as $item){ echo $item; } ?> @stop

 

test_layout.blade.php

<html>
    asdasdasd
    @yield('aaa')
</html>

 

如果你的views目录下有子目录,模板放子目录里面的话,比如

.
├── backend
│   ├── a.blade.php
│   ├── b.blade.php

a为模板,则b里面的extends需要

@extends('backend.a')

 

你可能感兴趣的:(laravel)