You can write conditionals inside your templates using the following Edge tags:

  • @if
  • @elseif
  • @else
  • @unless


  <p> Hello {{ username }}! </p>
  <p> Hello Guest </p>


@if(user.role === 'admin')
  <a href="/posts/1/edit"> Edit Post </a>
  <a href="/posts/1/delete"> Delete Post </a>
@elseif (user.role === 'moderator')
  <a href="/posts/1/edit"> Edit Post </a>


You can also use the unless tag for writing conditionals. The unless is the opposite of if and at times it feels more natural than writing a negative if.

  <a href="/login"> Login </a>

Ternary Operator

You can also write the standard Javascript ternary operator for shorthand if/else statements

<p>Hello {{ username ? username : 'Guest' }}</p>

On this page