0

Hi we are using the underscore.js library for some of our code:

{{ _.each(items, function(item) { }} 

    <li class="">
        <a class="title" href="{{= item.Id }}"><h2>{{= item.Name}}</h2></a>
        <p>{{= item.ShortDesc}}</p>
    </li>

{{ }); }}

Which will output:

<li><a><h2>Element 1</h2></a><p>Description of element 1</p></li>
<li><a><h2>Element 2</h2></a><p>Description of element 2</p></li>
...

But what we want is:

<li>
    <a><h2>Element 1</h2></a><p>Description of element 1</p>
    <a><h2>Element 2</h2></a><p>Description of element 2</p>
</li>
<li>
    <a><h2>Element 3</h2></a><p>Description of element 3</p>
    <a><h2>Element 4</h2></a><p>Description of element 4</p>
</li>
...

Basically, fill the <li> every 2 items using the _.each.

Please advise. Thanks

Danziger
  • 19,628
  • 4
  • 53
  • 83
doglin
  • 1,651
  • 4
  • 28
  • 38
  • can you not just put them in there? It seems like that takes html so why can't you just add the extra elements inside the li? – dbarnes May 19 '15 at 17:28
  • @doglin Did anyone solve your problem? If so, could you please accept the best answer (click the checkmark under the points). That will help other users that come across your question quickly spot the accepted answer and it also gives 15 rep. points to the author (: – Danziger Jan 31 '18 at 06:12