条件语句
jade支持js中的if/elseif/else
语法。
jade:
- 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
html:
<div id="user">
<h2>Description</h2>
<p class="description">foo bar baz</p>
</div>
unless
jade还支持反面的条件语句unless
。
jade:
- var user = { name: 'Tom' }
unless user.isAnonymous
p You're logged in as #{user.name}
html:
<p>You're logged in as Tom</p>