elektrobober elektrobober - 11 days ago 5
Jade Question

Show two items in one row in each loop using Jade

I have some issue with Each loop in Jade. I have to show 2 items in the row, but it doesn't work for me.

each item,i in feature.items
.col-mb-8.col-tb-12.col-dt-6
h4.b--feature__title!=item.title
p.b--feature__text!=item.text


and I need to add .col-group before odd items. Is it possible with Jade? Can someone help me, please?

Answer

And I finally find solution, that work for me

    each  item,i in feature.items
        - if (i.substr(4)%2) {
            | <div class='col-group'>
        - }
            .col-mb-8.col-tb-12.col-dt-6
                h4.b--feature__title!=item.title
                p.b--feature__text!=item.text
        - if (i.substr(4)%2 == 0)  {
            | </div>
        - }

and this render to

<div class="col-group">
  <div class="col-mb-8 col-tb-12 col-dt-6">
    <h4 class="b--feature__title">heade</h4>
    <p class="b--feature__text">text</p>
  </div>
  <div class="col-mb-8 col-tb-12 col-dt-6">
    <h4 class="b--feature__title">heade</h4>
    <p class="b--feature__text">text</p>
  </div>
</div>
<div class="col-group">
  <div class="col-mb-8 col-tb-12 col-dt-6">
    <h4 class="b--feature__title">heade</h4>
    <p class="b--feature__text">text</p>
  </div>
  <div class="col-mb-8 col-tb-12 col-dt-6">
    <h4 class="b--feature__title">heade</h4>
    <p class="b--feature__text">text</p>
  </div>
</div>