Do the indents in an else block continue from the then block?

前端 未结 2 1254
旧巷少年郎
旧巷少年郎 2021-01-21 02:26

The following Pug script:

- data = [ \"A\", \"B\", \"C\", \"D\" ]
- for (i=0,i

        
2条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-21 02:42

    Pug, by nature, doesn't allow that kind of "extra" indentation within the else block. To achieve your desired result, you could think about it like this—

    - var data = [ "A", "B", "C", "D" ]
    
    each datum, index in data
      if ((index % 2) == 0)
        .row
          .col #{datum}
          if (data[index + 1])
            .col #{data[index + 1]}
    

    —which yields—

    A
    B
    C
    D

提交回复
热议问题