laravel模板使用
{{ $var }}
- 打印內容
{{ $var or ‘default‘ }}
- 打印內容並帶一個默認值
{{{ $var }}}
- 打印轉義內容
{{-- Comment --}}
- 註釋
@extends(‘layout‘)
- 繼承模板‘layout’
@if(condition)
- if開始
@else
- else不帶條件
@elseif(condition)
- else帶條件
@endif
- 結束if
@foreach($list as $key => $val)
- foreach使用
@endforeach
- 結束foreach
@for($i = 0; $i < 10; $i++)
- for循環開始
@endfor
- for循環結束
@while(condition)
- while循環開始
@endwhile
- while循環結束
@unless(condition)
- unless開始
@endunless
- unless結束
include(file)
- 包含其他模板
@include(file, [‘var‘ => $val,...])
- 包含模板並傳輸新變量
@each(‘file‘,$list,‘item‘)
- 把一個模板放在一個集合中
@each(‘file‘,$list,‘item‘,‘empty‘)
@yield(‘section‘)
- 說明塊內容,用法類似section
@show
- 結束section並展示section內容
@lang(‘message‘)
- 從翻譯表格中輸出內容
@choice(‘message‘, $count)
- Outputs message with language pluralization
@section(‘name‘)
- 開始section
@stop
- 結束section並不顯示內容
@endsection
-結束section(laravel4後不建議使用)
@append
- (擴展section)
@overwrite
- 重寫section(之前的section內容全清除)
laravel模板使用