Jade Inline Conditional

后端 未结 7 1595
你的背包
你的背包 2021-01-31 15:43

I\'m trying to make everything apart from the first element in an array have a CSS class using the Jade templating engine.

I was hoping I could do it like this, but no l

7条回答
  •  执笔经年
    2021-01-31 16:25

    This is my solution. I'm using a mixin to pass the current active path and in the mixin I define the complete menu and always pass an if to check if the path is the active path.

    mixin adminmenu(active)
      ul.nav.nav-list.well
        li.nav-header Hello
        li(class="#{active=='/admin' ? 'active' : ''}")
          a(href="/admin") Admin
    

提交回复
热议问题