laravel 中blade 模板最基础的应用
视图 用 . 来区分层级
return view('admin.index' , {'title'=>'this is title'});
获取是否存在这个视图
Facades(读音:/fəˈsäd/ )为应用程序的 服务容器 中可用的类提供了一个「静态」接口。
use Illuminate\Support\Facades\View; if( View::exists('admin.index')) { }
传递解析单独的变量
return view('green')->with('type' , 'light');
模板中使用 <?php echo $type , $light; ?>
共享数据给所有的视图
http://d.laravel-china.org/docs/5.4/views#把数据共享给所有视图
laravel 的视图合成器
http://www.cnblogs.com/chenqionghe/p/4881467.html
controller 给模板进行传递参数的方式
return view('article/article_content', ['title'=>$title ]);
return view('article/article_content', compact('article'));
blade 模板中的判断和循环
@if() @endif @foreach() @endforeach
* Blade 模板基础使用 *
resources/views/layout/main.blade.php
@include('layout.header') @yield('content') @include('layout.footer')
resources/views/layout/articlecontent.blade.php
@extends('layout.main') @section('content')
... ... ... ... @endsection

浙公网安备 33010602011771号