玉有条件 - 没有if的意外

时间:2015-08-28 19:52:18

标签: node.js pug

block main
  h2.content-heading My profile
  .block
    .block-content.block-content-full
      a.block.block-link-hover2(href="#" data-toggle="modal" data-target="#modal-fadein" type="button")
        .block-header
            //- h3.block-title.text-center Author of the Month
        div(class="block-content block-content-full text-center bg-image" style=(account.backgroundImage))
          div
            img.img-avatar.img-avatar96.img-avatar-thumb(src=(account.avatar), alt='')
          .h5.text-white.push-15-t.push-5 #{account.displayname}
        .block-content
          .row.items-push.text-center
            .col-xs-6.col-xs-offset-3
              .push-5
            if account.premium
                i.fa.fa-bolt.fa-2x(style="color: #FF9800;")
              .h5.font-w300.text-muted Premium member
            else 
                i.fa.fa-thumbs-up.fa-2x(style="color: #3c3c3c;")
              .h5.font-w300.text-muted Free user

错误:

Unexpected else without if

我通过res.render传递account.premium为假。除了if / else块之外,帐户对象下的其他所有内容都正常工作。

1 个答案:

答案 0 :(得分:2)

缩进很重要。

工作代码: if account.premium i.fa.fa-bolt.fa-2x(style="color: #FF9800;") .h5.font-w300.text-muted Premium member else i.fa.fa-thumbs-up.fa-2x(style="color: #3c3c3c;") .h5.font-w300.text-muted Free user