0

I want to output an iterative list of:

<div class='X'>  //or plain <div> depending on boolean X
  <div class='d1'>
    <div class='d2'>
      ...
    </div>
  </div>
</div>

The Jade script is:

each r in rList
   -if (X)
       div.X
          div.d1
             div.d2
   -else
       div
          div.d1
             div.d2

How do I do it with just one set of d1 and d2 which are the same in both situations?

Old Geezer
  • 14,854
  • 31
  • 111
  • 198
  • Possible duplicate http://stackoverflow.com/questions/14144274/jade-conditional-if-else-to-add-class-to-div-inline – drinchev Dec 02 '16 at 09:29
  • Hi, thanks. I could solve this particular (simple) problem of mine by converting to an inline conditional expression. I wonder if there is a more generic way to specify indents to achieve the hierarchy I need. – Old Geezer Dec 02 '16 at 11:00

1 Answers1

0
each r in rList
  div(class=X ? X : '')
    div.d1
      div.d2

or you can drop the 'div's:

each r in rList
  div(class=X ? X : '')
    .d1
      .d2
Avraham
  • 916
  • 1
  • 13
  • 25