Zing. compile-to-PHP template engine GitHub ↗

Conditionals

Zing provides conditional directives that compile to PHP conditionals.

@if

@if($user->isAdmin())
    admin
@elseif($user->isMod())
    mod
@else
    guest
@endif

@unless

@unless is the inverse of @if:

@unless($user->isBanned())
    welcome
@endunless

@isset

@isset($user->avatar)
    has an avatar
@endisset

@empty

@empty($course->students)
    no students yet
@endempty

@unless, @isset, and @empty compile to the corresponding PHP conditional checks. Their named closing directives are aliases for the normal PHP conditional closing output.