Blade Syntax Highlighting Tests

{{-- Displaying Data --}} Hello, {{ $name }}. The current UNIX timestamp is {{ time() }}. {{-- Escape Data --}} Hello, {{{ $name }}}. {{-- Echoing Data If It Exists --}} {{ isset($name) ? $name : 'Default' }} {{ $name or 'Default' }}
{{-- Displaying Unescaped Data --}} Hello, {!! $name !!}. {{-- Rendering JSON --}} {{-- Blade & JavaScript Frameworks --}} Hello, @{{ name }}. {{-- Blade --}} @@json() @json() @verbatim
Hello, {{ name }}.
@endverbatim {{-- Control Structures --}} {{-- If Statements --}} @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 @isset($records) // $records is defined and is not null... @endisset @empty($records) // $records is "empty"... @endempty {{-- Authentication Directives --}} @auth // The user is authenticated... @endauth @guest // The user is not authenticated... @endguest @auth('admin') // The user is authenticated... @endauth @guest('admin') // The user is not authenticated... @endguest {{-- Section Directives --}} @hasSection('navigation')
@yield('navigation')
@endif @sectionMissing('navigation')
@include('default-navigation')
@endif {{-- Environment Directives --}} @production // Production specific content... @endproduction @env('staging') // The application is running in "staging"... @endenv @env(['staging', 'production']) // The application is running in "staging" or "production"... @endenv {{-- Section Directives --}} @hasSection('navigation')
@yield('navigation')
@endif @sectionMissing('navigation')
@include('default-navigation')
@endif {{-- Switch Statements --}} @switch($i) @case(1) First case... @break @case(2) Second case... @break @default Default case... @endswitch {{-- Loops --}} @for ($i = 0; $i < 10; $i++) The current value is {{ $i }} @endfor @foreach ($users as $user)

This is user {{ $user->id }}

@endforeach @forelse ($users as $user)
  • {{ $user->name }}
  • @empty

    No users

    @endforelse @while (true)

    I'm looping forever.

    @endwhile {{-- continue & break --}} @foreach ($users as $user) @if ($user->type == 1) @continue @endif
  • {{ $user->name }}
  • @if ($user->number == 5) @break @endif @continue($user->type == 1)
  • {{ $user->name }}
  • @break($user->number == 5) @endforeach @foreach ($users as $user) @continue($user->type == 1)
  • {{ $user->name }}
  • @break($user->number == 5) @endforeach {{-- The Loop Variable --}} @foreach ($users as $user) @if ($loop->first) This is the first iteration. @endif @if ($loop->last) This is the last iteration. @endif

    This is user {{ $user->id }}

    {{-- $loop->parent --}} @foreach ($user->posts as $post) @if ($loop->parent->first) This is the first iteration of the parent loop. @endif @endforeach @endforeach {{-- Loop Variables --}} {{-- The index of the current loop iteration (starts at 0) --}} {{ $loop->index }} {{-- The current loop iteration (starts at 1) --}} {{ $loop->iteration }} {{-- The iteration remaining in the loop --}} {{ $loop->remaining }} {{-- The total number of items in the array being iterated --}} {{ $loop->count }} {{-- Whether this is the first iteration through the loop --}} {{ $loop->first }} {{-- Whether this is the last iteration through the loop --}} {{ $loop->last }} {{-- The nesting level of the current loop --}} {{ $loop->depth }} {{-- When in a nested loop, the parent's loop variable --}} {{ $loop->parent }} @endforeach {{-- Comments --}} {{-- This comment will not be present in the rendered HTML --}} {{-- This comment will not be in the rendered HTML This comment will not be in the rendered HTML This comment will not be in the rendered HTML --}} {{-- PHP --}} format('m/d/Y H:i'); ?> @php ($hello = "hello world") @php foreach (range(1, 10) as $number) { echo $number; } @endphp {{-- Conditional Classes : `@class` directive --}} @php $isActive = false; $hasError = true; @endphp $isActive, 'text-gray-500' => ! $isActive, 'bg-red' => $hasError, ])> {{-- The @once Directive --}} @once @push('scripts') @endpush @endonce {{-- Forms --}}
    @csrf @method('PUT')
    {{-- Validation Errors --}} @error('title')
    {{ $message }}
    @enderror {{-- Components --}} {{-- Component attribute expressions --}} {{-- Including Sub-Views --}}
    @include('shared.errors')
    @include('view.name') @include('view.name', ['some' => 'data']) @includeIf('view.name', ['some' => 'data']) @includeWhen($boolean, 'view.name', ['some' => 'data']) @includeUnless($boolean, 'view.name', ['some' => 'data']) @includeFirst(['custom.admin', 'admin'], ['some' => 'data']) {{-- Rendering Views For Collections --}} @each('view.name', $jobs, 'job') @each('view.name', $jobs, 'job', 'view.empty') {{-- Stacks --}} @push('scripts') @endpush @stack('scripts') @prepend('scripts') This will be first... @endprepend {{-- Service Injection --}} @inject('metrics', 'App\Services\MetricsService')
    Monthly Revenue: {{ $metrics->monthlyRevenue() }}.
    {{-- Retrieving Translation Strings --}} @lang('messages.welcome') {{-- 5.3 --}} {{ trans('messages.welcome') }} {{-- 5.4 --}} {{ __('messages.welcome') }} {{-- Pluralization --}} @choice('messages.apples', 10) {{-- 'apples' => '{0} There are none|[1,19] There are some|[20,Inf] There are many', --}} {{ trans_choice('messages.apples', 10) }} {{-- Replacing Parameters In Translation Strings --}} {{-- 'greeting' => 'Welcome, :name', --}} {{ __('messages.greeting', ['name' => 'Winnie']) }} {{-- Authorizing --}} @can('update', $post) @elsecan('create', App\Models\Post::class) @endcan @canany(['update'], $post) @elsecanany(['create'], App\Models\Post::class) @endcanany @cannot('update', $post) @elsecannot('create', App\Models\Post::class) @endcannot @if (Auth::user()->can('update', $post)) @endif @unless (Auth::user()->can('update', $post)) @endunless @can('create', App\Models\Post::class) @endcan @canany(['create'], App\Models\Post::class) @endcanany @cannot('create', App\Models\Post::class) @endcannot {{-- Retrieving Translation Strings --}} {{ __('messages.welcome') }} @lang('messages.welcome') @props(['type' => 'info', 'message']) {{-- Envoy --}} @setup require __DIR__.'/vendor/autoload.php'; $dotenv = new Dotenv\Dotenv(__DIR__); @endsetup @servers(['web' => $server]) @task('init') if [ ! -d {{ $path }}/current ]; then cd {{ $path }} @endtask @story('deploy') deployment_start deployment_composer deployment_finish @endstory {{-- Livewire --}} @livewireStyles @livewireScripts @livewire('user-profile', ['user' => $user], key($user->id)) {{-- Checked / Selected / Disabled Blade Directives (9.x) --}} active)) />