Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save icheernoom/03145d6af7e324375de8d541acce09d2 to your computer and use it in GitHub Desktop.
Save icheernoom/03145d6af7e324375de8d541acce09d2 to your computer and use it in GitHub Desktop.

Revisions

  1. @CiprianSpiridon CiprianSpiridon revised this gist Oct 27, 2014. 1 changed file with 31 additions and 32 deletions.
    63 changes: 31 additions & 32 deletions Laravel-Blade-Template-Cheatsheet
    Original file line number Diff line number Diff line change
    @@ -1,32 +1,31 @@
    <ul>
    <li><code>{{ $var }}</code> - Echo content</li>
    <li><code>{{ $var or 'default' }}</code> - Echo content with a default value</li>
    <li><code>{{{ $var }}}</code> - Echo escaped content</li>
    <li><code>{{-- Comment --}}</code> - A Blade comment</li>
    <li><code>@extends('layout')</code> - Extends a template with a layout</li>
    <li><code>@if(condition)</code> - Starts an <strong>if</strong> block</li>
    <li><code>@else</code> - Starts an <strong>else</strong> block</li>
    <li><code>@elseif(condition)</code> - Start a <strong>elseif</strong> block</li>
    <li><code>@endif</code> - Ends a <strong>if</strong> block</li>
    <li><code>@foreach($list as $key =&gt; $val)</code> - Starts a <strong>foreach</strong> block</li>
    <li><code>@endforeach</code> - Ends a <strong>foreach</strong> block</li>
    <li><code>@for($i = 0; $i &lt; 10; $i++)</code> - Starts a <strong>for</strong> block</li>
    <li><code>@endfor</code> - Ends a <strong>for</strong> block</li>
    <li><code>@while(condition)</code> - Starts a <strong>while</strong> block</li>
    <li><code>@endwhile</code> - Ends a <strong>while</strong> block</li>
    <li><code>@unless(condition)</code> - Starts an <strong>unless</strong> block</li>
    <li><code>@endunless</code> - Ends an <strong>unless</strong> block</li>
    <li><code>@include(file)</code> - Includes another template</li>
    <li><code>@include(file, ['var' =&gt; $val,...])</code> - Includes a template, passing new variables.</li>
    <li><code>@each('file',$list,'item')</code> - Renders a template on a collection</li>
    <li><code>@each('file',$list,'item','empty')</code> - Renders a template on a collection or a different template if collection is empty.</li>
    <li><code>@yield('section')</code> - Yields content of a section.</li>
    <li><code>@show</code> - Ends section and yields its content</li>
    <li><code>@lang('message')</code> - Outputs message from translation table</li>
    <li><code>@choice('message', $count)</code> - Outputs message with language pluralization</li>
    <li><code>@section('name')</code> - Starts a section</li>
    <li><code>@stop</code> - Ends section</li>
    <li><code>@endsection</code> - Ends section</li>
    <li><code>@append</code> - Ends section and appends it to existing of section of same name</li>
    <li><code>@overwrite</code> - Ends section, overwriting previous section of same name</li>
    </ul>

    {{ $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
  2. @CiprianSpiridon CiprianSpiridon revised this gist Oct 27, 2014. 1 changed file with 32 additions and 30 deletions.
    62 changes: 32 additions & 30 deletions Laravel-Blade-Template-Cheatsheet
    Original file line number Diff line number Diff line change
    @@ -1,30 +1,32 @@
    {{ $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
    <ul>
    <li><code>{{ $var }}</code> - Echo content</li>
    <li><code>{{ $var or 'default' }}</code> - Echo content with a default value</li>
    <li><code>{{{ $var }}}</code> - Echo escaped content</li>
    <li><code>{{-- Comment --}}</code> - A Blade comment</li>
    <li><code>@extends('layout')</code> - Extends a template with a layout</li>
    <li><code>@if(condition)</code> - Starts an <strong>if</strong> block</li>
    <li><code>@else</code> - Starts an <strong>else</strong> block</li>
    <li><code>@elseif(condition)</code> - Start a <strong>elseif</strong> block</li>
    <li><code>@endif</code> - Ends a <strong>if</strong> block</li>
    <li><code>@foreach($list as $key =&gt; $val)</code> - Starts a <strong>foreach</strong> block</li>
    <li><code>@endforeach</code> - Ends a <strong>foreach</strong> block</li>
    <li><code>@for($i = 0; $i &lt; 10; $i++)</code> - Starts a <strong>for</strong> block</li>
    <li><code>@endfor</code> - Ends a <strong>for</strong> block</li>
    <li><code>@while(condition)</code> - Starts a <strong>while</strong> block</li>
    <li><code>@endwhile</code> - Ends a <strong>while</strong> block</li>
    <li><code>@unless(condition)</code> - Starts an <strong>unless</strong> block</li>
    <li><code>@endunless</code> - Ends an <strong>unless</strong> block</li>
    <li><code>@include(file)</code> - Includes another template</li>
    <li><code>@include(file, ['var' =&gt; $val,...])</code> - Includes a template, passing new variables.</li>
    <li><code>@each('file',$list,'item')</code> - Renders a template on a collection</li>
    <li><code>@each('file',$list,'item','empty')</code> - Renders a template on a collection or a different template if collection is empty.</li>
    <li><code>@yield('section')</code> - Yields content of a section.</li>
    <li><code>@show</code> - Ends section and yields its content</li>
    <li><code>@lang('message')</code> - Outputs message from translation table</li>
    <li><code>@choice('message', $count)</code> - Outputs message with language pluralization</li>
    <li><code>@section('name')</code> - Starts a section</li>
    <li><code>@stop</code> - Ends section</li>
    <li><code>@endsection</code> - Ends section</li>
    <li><code>@append</code> - Ends section and appends it to existing of section of same name</li>
    <li><code>@overwrite</code> - Ends section, overwriting previous section of same name</li>
    </ul>
  3. @CiprianSpiridon CiprianSpiridon revised this gist Oct 27, 2014. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions Laravel-Blade-Template-Cheatsheet
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,8 @@

    {{ $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
    `@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
  4. @CiprianSpiridon CiprianSpiridon created this gist Oct 27, 2014.
    31 changes: 31 additions & 0 deletions Laravel-Blade-Template-Cheatsheet
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@

    {{ $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