Credit to




Pug’s first-class conditional syntax allows for optional parentheses.

If you’re coming from Pug v1, you may now omit the leading -. Otherwise, it’s identical (just regular JavaScript):

- var user = { description: 'foo bar baz' }
- var authorised = false
  if user.description Description
    p.description= user.description
  else if authorised Description
      User has no description,
      why not add one...
  else Description
    p.description User has no description
<div id="user">
  <h2 class="green">Description</h2>
  <p class="description">foo bar baz</p>

Pug also provides the conditional unless, which works like a negated if. The following are equivalent:

unless user.isAnonymous
  p You're logged in as #{}
if !user.isAnonymous
  p You're logged in as #{}

© Pug authors
Licensed under the MIT license.