There is an output of elements through the construction each in Jade. I need to wrap every 2 elements in a div-parent, how can this be implemented? I wrote the following code:

 each item,i in feature.items - if (i.substr(4)%2) { .col-group .col-mb-8.col-tb-12.col-dt-6 h4.b--feature__title!=item.title pb--feature__text!=item.text - } else { .col-mb-8.col-tb-12.col-dt-6 h4.b--feature__title!=item.title pb--feature__text!=item.text - } 

But it does not work correctly and wraps only the first .col-mb-8 element out of two in the .col-group . How to add the second?

  • what does "every two" mean? I personally understand it like this - we got it first, hung it up in the fifth dimension, moved on to the next one. They took the next one, created a splitting space machine and took out the first element from there and wrapped it ... If so, first sort the array by combining two elements (using javascript), and only then, as usual. - user220409

0