jade: if statements and nesting

前端 未结 3 1611
孤街浪徒
孤街浪徒 2021-02-07 07:41

Concider this pseudo-ish server side code

if(isFixed) {
  
} else {
}

Inner element

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-07 08:12

    I would approach this with a ternary (or fully written out conditional or method) to determine the class attribute. That allows you to keep the div on one line and keeps indentation like it would be for any other element:

    div(class="#{ isFixed ? 'fixed' : '' }")
        p Inner Element
    

提交回复
热议问题