jade-if-else-unless-case

if else
- var lession = ['node','jade']
if lession
  if lession.length > 2
    p 1 #{lession.join(', ')}
  else if lession.length > 1
    p 2 #{lession.join(', ')}
  else
    p no lession
else
  p no lession
=>
<p>2 node, jade</p>

 

unless其实就是if的反向的判断
- var isJade = true
unless !isJade   p #{lession.length} =>
<p>2</p>

 

case在jade里面不写switch case,而是写case when
- var name = 'jade'
case name
  when 'java': p Hi java
  when 'jade': p Hi jade
  when 'node': p Hi node
  when 'express': p Hi express
=>
<p>Hi jade</p>

 

 

posted @ 2018-07-07 08:28  wzndkj  阅读(573)  评论(0编辑  收藏  举报