I find it difficult to find a way to do the following markup with Ember.Handlebars:
<div class="row-fluid">
<div class="span4">Item #1 (row #1 / column #1)</div>
<div class="span4">Item #2 (row #1 / column #2)</div>
<div class="span4">Item #3 (row #1 / column #3)</div>
</div>
<div class="row-fluid">
<div class="span4">Item #4 (row #2 / column #1)</div>
<div class="span4">Item #5 (row #2 / column #2)</div>
<div class="span4">Item #6 (row #2 / column #3)</div>
</div>
<div class="row-fluid">
<div class="span4">Item #7 (row #3 / column #1)</div>
</div>
Using pure JavaScript, Id did something like this:
var array = ['Item 1', 'Item 2', 'Item 3', 'Item 4', 'Item 5', 'Item 6', 'Item 7'],
output = '<div class="row-fluid">';
for (var i = 0, j = array.length; i < j; i++) {
output += '<div class="span4">' + i + '</div>';
if ((i + 1) % 3 == 0) {
output += '</div><div class="row-fluid">';
}
}
output += '</div>';
Ideally, Id puts this in a special Handlebars helper (thus removing the logic from the template), but the Ember Documentation explains how to write simple helpers, and I really can't write a more complex helper block without losing property bindings.
Does anyone know what is the best way to use Twitter Bootstraps grid with Ember model collection?
Thank you in advance! Regards,
David
source
share