Skip to content

Latest commit

History

History
29 lines (24 loc) 路 667 Bytes

conditionals.md

File metadata and controls

29 lines (24 loc) 路 667 Bytes
summary
Learn how to write conditionals inside Edge templates

You can write conditionals using the @if, @elseif and the @else tags. All three tags works similar to the JavaScript if/else statements.

@if(user)
  <p> {{ user.username }} </p>
@end
@if(user.fullName)
  <p> Hello {{ user.fullName }}! </p>
@elseif(user.firstName)
  <p> Hello {{ user.firstName }}! </p>
@else
  <p> Hello Guest! </p>
@end

The inverse of the @if tag is the @unless tag. You might find it expressive to write the NOT IF statements.

@unless(account.isActive)
  <p> Please verify the email address to activate your account </p>
@end