Question: How would I use AngularJS `ng-repeat` to display the following HTML (Twitter Bootstrap Scaffolding)? Essentially, every third record I need to close the `</div>`, print an `<hr>`, then open another `<div class="span4">` 

```
    <div class="row">
      <div class="span4">
        <h3>
          Project A
        </h3>
      </div>
      <div class="span4">
        <h3>
          Project B
        </h3>
      </div>
      <div class="span4">
        <h3>
          Project C
        </h3>
      </div>
    </div>

    <hr>

    <div class="row">
      <div class="span4">
        <h3>
          Project D
        </h3>
      </div>
      <div class="span4">
        <h3>
          Lab Title
        </h3>
      </div>
      <div class="span4">
        <h3>
          Project E
        </h3>
      </div>
    </div>

```

I've created a fiddle for code demos.  

<http://jsfiddle.net/ADukg/261/>

Answer: 
A more elegant way is to use the view model to provide a chunked collection and then let the view handle it like

```
<div ng-controller="Controller">
    Projects <input ng-model="projects"></input>
    <hr/>
    <div ng-repeat="row in rows">
        <div ng-repeat="project in row">
            Projects {{project}}
        </div>
        <hr/>
    </div>
</div>​

```

and the coffeescript is pretty simple

```
# Break up an array into even sized chunks.
chunk = (a,s)->
    if a.length == 0
        []
    else               
        ( a[i..i+s-1] for i in [0..a.length - 1 ] by s)

@Controller = ($scope)->
    $scope.projects = "ABCDEF"

    $scope.$watch "projects", ->      
       $scope.rows = chunk $scope.projects.split(""), 3

angular.bootstrap(document, []);

```

​

<http://jsfiddle.net/ADukg/370/>
[ng-repeat-start and ng-repeat-end end points](https://docs.angularjs.org/api/ng/directive/ngRepeat#special-repeat-start-and-end-points) seems a convenient way to achieve this :

Which leads to simple code

```
<div ng-controller="MyCtrl">
    <div ng-repeat-start="project in projects">
        <span>
            <div class="row">
                <h3 class="span4">{{project}}</h3>
            </div
        </span>
    </div>
    <hr ng-repeat-end ng-if="($index + 1) % 3 == 0" />
</div>

```

See this [jsfiddle](http://jsfiddle.net/grafmik/c0cu64r6/1/)