Skip to main content Svelte Highlight v7.21.1

Blade language preview

1. Conditionals and loops

@if / @foreach directives mixed with embedded HTML
horizon-dark
@if($user->isAdmin())
  <p>{{ $user->name }} is an admin.</p>
@endif
@foreach($items as $item)
  <li>{{ $item->label }}</li>
@endforeach
atom-one-dark
@if($user->isAdmin())
  <p>{{ $user->name }} is an admin.</p>
@endif
@foreach($items as $item)
  <li>{{ $item->label }}</li>
@endforeach
github-dark
@if($user->isAdmin())
  <p>{{ $user->name }} is an admin.</p>
@endif
@foreach($items as $item)
  <li>{{ $item->label }}</li>
@endforeach
dracula
@if($user->isAdmin())
  <p>{{ $user->name }} is an admin.</p>
@endif
@foreach($items as $item)
  <li>{{ $item->label }}</li>
@endforeach
nord
@if($user->isAdmin())
  <p>{{ $user->name }} is an admin.</p>
@endif
@foreach($items as $item)
  <li>{{ $item->label }}</li>
@endforeach
github
@if($user->isAdmin())
  <p>{{ $user->name }} is an admin.</p>
@endif
@foreach($items as $item)
  <li>{{ $item->label }}</li>
@endforeach

2. PHP block and comments

@php ... @endphp with a Blade comment
horizon-dark
@php
  $total = $subtotal + $tax;
@endphp
{{-- shown only when the cart has items --}}
@unless(empty($cart))
  <span>Total: {{ $total }}</span>
@endunless
atom-one-dark
@php
  $total = $subtotal + $tax;
@endphp
{{-- shown only when the cart has items --}}
@unless(empty($cart))
  <span>Total: {{ $total }}</span>
@endunless
github-dark
@php
  $total = $subtotal + $tax;
@endphp
{{-- shown only when the cart has items --}}
@unless(empty($cart))
  <span>Total: {{ $total }}</span>
@endunless
dracula
@php
  $total = $subtotal + $tax;
@endphp
{{-- shown only when the cart has items --}}
@unless(empty($cart))
  <span>Total: {{ $total }}</span>
@endunless
nord
@php
  $total = $subtotal + $tax;
@endphp
{{-- shown only when the cart has items --}}
@unless(empty($cart))
  <span>Total: {{ $total }}</span>
@endunless
github
@php
  $total = $subtotal + $tax;
@endphp
{{-- shown only when the cart has items --}}
@unless(empty($cart))
  <span>Total: {{ $total }}</span>
@endunless

3. Layout inheritance

@extends, @section, and unescaped output
horizon-dark
@extends('layouts.app')

@section('content')
  <h1>{{ $title }}</h1>
  {!! $rawHtml !!}
@endsection
atom-one-dark
@extends('layouts.app')

@section('content')
  <h1>{{ $title }}</h1>
  {!! $rawHtml !!}
@endsection
github-dark
@extends('layouts.app')

@section('content')
  <h1>{{ $title }}</h1>
  {!! $rawHtml !!}
@endsection
dracula
@extends('layouts.app')

@section('content')
  <h1>{{ $title }}</h1>
  {!! $rawHtml !!}
@endsection
nord
@extends('layouts.app')

@section('content')
  <h1>{{ $title }}</h1>
  {!! $rawHtml !!}
@endsection
github
@extends('layouts.app')

@section('content')
  <h1>{{ $title }}</h1>
  {!! $rawHtml !!}
@endsection