Conditionals
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
#user
if user.description
h2 Description
p.description= user.description
else if authorised
h2 Description
p.description.
User has no description,
why not add one...
else
h1 Description
p.description User has no description
<div id="user">
<h2>Description</h2>
<p class="description">foo bar baz</p>
</div>
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}