标签:
<!-- app/views/example.blade.php --><p>{{ date(‘d/m/y‘) }}</p>
<!-- app/views/example.blade.php --><p>{{{ ‘<script>alert("CHUNKY BACON!");</script>‘ }}}</p>
特殊字符串将被自动转义,最终结果如下:
<!-- app/views/example.blade.php --><p><script>alert("CHUNKY BACON!");</script></p>
<!-- app/views/example.blade.php -->@if ($something == ‘Red Panda‘) <p>Something is red, white, and brown!</p>@elseif ($something == ‘Giant Panda‘) <p>Something is black and white!</p>@else <p>Something could be a squirrel.</p>@endif
<!-- app/views/example.blade.php -->@foreach ($manyThings as $thing) <p>{{ $thing }}</p>@endforeach
<!-- app/views/example.blade.php -->@for ($i = 0; $i < 999; $i++)
<p>Even {{ $i }} red pandas, aren‘t enough!</p>@endfor
<!-- app/views/example.blade.php -->@while (isPretty($kieraKnightly)) <p>This loop probably won‘t ever end.</p>@endwhile
<!-- app/views/example.blade.php -->@unless (worldIsEnding()) <p>Keep smiling.</p>@endunless
<html lang="en"><h1>When does the Narwhal bacon?</h1><!-- app/views/footer.blade.php --><small>Information provided based on research as of 3rd May ‘13.</small><!-- app/views/example.blade.php --><!doctype html><html lang="en"><head> <meta charset="UTF-8"> <title>Narwhals</title></head><body> @include(‘header‘) <p>Why, the Narhwal surely bacons at midnight, my good sir!</p> @include(‘footer‘)</body></html>
<html lang="en"><!doctype html><html lang="en"><head> <meta charset="UTF-8"> <title></title> @section(‘head‘) <link rel="stylesheet" href="style.css" /> @show</head><body> @yield(‘body‘) @section(‘message‘) @parent <p>parent message.</p> @show</body></html><!-- app/views/home.blade.php -->@extends(‘layouts.base‘) @section(‘head‘) <link rel="stylesheet" href="another.css" />@stop @section(‘body‘) <h1>Hurray!</h1> <p>We have a template!</p>@stop @section(‘message‘) @parent <p>Fourth</p>@stop
{{-- This is a pretty, and secret Blade comment. --}}
{{ $var }} - Echo content
{{ $var or ‘default‘ }} - Echo content with a default value
{{{ $var }}} - Echo escaped content
{{-- Comment --}} - A Blade comment
@extends(‘layout‘) - Extends a template with a layout
@if(condition) - Starts an if block
@else - Starts an else block
@elseif(condition) - Start a elseif block
@endif - Ends a if block
@foreach($list as $key => $val) - Starts a foreach block
@endforeach - Ends a foreach block
@for($i = 0; $i < 10; $i++) - Starts a for block
@endfor - Ends a for block
@while(condition) - Starts a while block
@endwhile - Ends a while block
@unless(condition) - Starts an unless block
@endunless - Ends an unless block
include(file) - Includes another template
@include(file, [‘var‘ => $val,...]) - Includes a template, passing new variables.
@each(‘file‘,$list,‘item‘) - Renders a template on a collection
@each(‘file‘,$list,‘item‘,‘empty‘)- Renders a template on a collection or a different template if collection is empty.
@yield(‘section‘) - Yields content of a section.
@show - Ends section and yields its content
@lang(‘message‘) - Outputs message from translation table
@choice(‘message‘, $count) - Outputs message with language pluralization
@section(‘name‘) - Starts a section
@stop - Ends section
@endsection - Ends section
@append - Ends section and appends it to existing of section of same name
@overwrite - Ends section, overwriting previous section of same name
标签:
原文地址:http://my.oschina.net/u/573270/blog/483549