https://github.com/Fuitad/laravel-blade
Raw File
Tip revision: 7e3a210652947a49674abd6f7a12008007c2593d authored by Eric Percifield on 08 October 2015, 17:57:51 UTC
Release st3-1.5.6.
Tip revision: 7e3a210
test.blade
{{-- Echo Data --}}
Hello, {{ $name }}.
The current UNIX timestamp is {{ time() }}.

{{-- Echoing Data After Checking For Existence --}}
{{ isset($name) ? $name : 'Default' }}
{{ $name or 'Default' }}

{{-- Displaying Raw Text With Curly Braces --}}
@{{ This will not be processed by Blade }}

{{-- Do not escape data --}}
Hello, {!! $name !!}.

{{-- Escape Data --}}
Hello, {{{ $name }}}.

{{-- Define Blade Layout --}}
<html>
    <body>
        @section('sidebar')
            This is the master sidebar.
        @stop

        <div class="container">
            @yield('content')
        </div>
    </body>
</html>

{{-- Use Blade Layout --}}
@extends('layouts.master')

@section('sidebar')


    <p>This is appended to the master sidebar.</p>
@stop

@section('content')
    <p>This is my body content.</p>
@stop

{{-- --}}
@yield('section', 'Default Content')

{{-- If Statement --}}
@if (count($records) === 1)
    I have one record!
@elseif (count($records) > 1)
    I have multiple records!
@else
    I don't have any records!
@endif

@unless (Auth::check())
    You are not signed in.
@endunless

{{-- Loops --}}
@for ($i = 0; $i < 10; $i++)
    The current value is {{ $i }}
@endfor

@foreach ($users as $user)
    <p>This is user {{ $user->id }}</p>
@endforeach

@forelse($users as $user)
      <li>{{ $user->name }}</li>
@empty
      <p>No users</p>
@endforelse

@while (true)
    <p>I'm looping forever.</p>
@endwhile

{{-- Include --}}
@include('view.name')
@include('view.name', ['some' => 'data'])

{{-- Overwriting Sections --}}
@extends('list.item.container')

@section('list.item.content')
    <p>This is an item of type {{ $item->type }}</p>
@overwrite

{{-- Displaying Language Lines --}}
@lang('language.line')

@choice('language.line', 1)

{{-- This comment will not be in the rendered HTML --}}
{{--

This comment will not be in the rendered HTML

--}}

{{-- Custom Control Structures --}}
@custom

@foo('bar', 'baz')
    @datetime($var)
back to top