Edited to include angular code (for illustration purposes only)
I've been trying to find away in AngularJS to auto wrap columns in rows after n columns whilst not affecting the index.
<div class="row">
{{for (var i = 0; i < list.length; i++ ) { }}
<div class="col-4">list[0].name</div>
{{ } }}
This is how it'd be done in PHP below.
In short:
<div class="row">
<?php
$collection = array( 'item1',
'item2',
'item3',
'item4',
'item5',
);
for($i = 0; $i < count($collection); $i++ ) : ?>
<div class="col-4">
<?php echo $collection[$i] ?>
</div>
<?php if(($i + 1) % 3 === 0) :?>
</div> <!-- close row -->
<div class="row"><!-- open new row -->
<?php endif ?>
<?php endfor ?>
</div> <!-- close final row -->
I know it can be done within a controller and pushed back into the DOM within a link function, but that just seems horrible. I'm sure I must be missing something, but conditionally adding the closing div before the opening one is proving tricky for me.
P.S. I considered doing the example using Underscore.js, but felt this would be a little more universal.