Jade - Node Template Engine


Jade's first-class conditional syntax allows for optional parenthesis, and you may now omit the leading - otherwise it's identical, still just regular javascript:

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

Jade also provides a negated version unless (the following are therefore equivalent):

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