Syntax overview
Propel's syntax follows Blade. Each part below has a page with examples.
Output
{{ $name }}prints a value, escaped for HTML. See escaping.- The raw-output tag,
{!! $html !!}, prints a value without escaping. Use it only for trusted content. - A comment goes between the echo braces, wrapped in two dashes on each side. It is not sent to the browser.
{{prints a literal{{, and{!!prints a literal{!!, for code samples and JavaScript.
Conditions
@if ($user)
Hello, {{ $user.name }}
@elseif ($guest)
Welcome
@else
Please sign in
@endif
A value is false when it is null or false, zero, an empty string, or an empty list. A struct is true. See control flow.
Loops
@foreach (post in posts)
{{ $post.title }}
@endforeach
@forelse (post in posts)
{{ $post.title }}
@empty
No posts yet.
@endforelse
A null list counts as empty, so @empty shows.
Layouts and sections
@extends('layouts.app')
@section('content')
The page content.
@endsection
The layout places each section where it calls @yield('content'). A section must be at the top level of the view, not inside an @if or a loop.
Defaults, @parent, @show, partials with @include, and stacks are on the layouts and sections page.
Assets
asset('resources/images/logo.svg') returns the URL of a file, and @vite([...]) loads entries. See images, fonts and assets.
Debugging
@dump($value)prints a value and keeps rendering. See @dump.@dd($value)is "dump and die", as in Laravel: it prints a value and stops rendering the section it is in. The layout still finishes, so the page loads. See @dd.
Debug helpers render only in development builds.
Writing a directive as text
A directive word in plain text needs two @ signs in front of it in the template, so Propel prints one. Email addresses and CSS rules such as @media need no escape, because Propel only reads the directive words it knows.
Propel