条件句(Conditionals)

¥Conditionals

Pug 的一流条件语法允许使用可选的括号。

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

如果你来自 Pug v1,你现在可以省略开头的 -。否则,它是相同的(只是常规的 JavaScript):

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

Pug 还提供了条件 unless,其作用类似于否定 if。以下是等效的:

¥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 #{user.name}
if !user.isAnonymous
  p You're logged in as #{user.name}
Pug 中文网 - 粤ICP备13048890号