5

I have a collection of items, that I would like to stuff into a bootstrap grid. This then looks like this:

 <div class="row">
  <div class="col-md-8">.col-md-8</div>
  <div class="col-md-4">.col-md-4</div>
</div>
<div class="row">
 <div class="col-md-8">.col-md-8</div>
 <div class="col-md-4">.col-md-4</div>
</div>

So I would need to loop through my collection and adding after every second item

There are two issues:

  • invalid html! No idea how to get around this
  • Issues with the module, but I think with some helpers I could get around.

Best would be if there were some examples.

Thanks for any inputs

rapsli
  • 749
  • 1
  • 8
  • 23
  • possible duplicate of [How do I populate a bootstrap grid system using handlebars for each command in Meteor.js?](http://stackoverflow.com/questions/18674346/how-do-i-populate-a-bootstrap-grid-system-using-handlebars-for-each-command-in-m) – ChatGPT Jul 27 '14 at 10:11

2 Answers2

0

check out this question. you should be searching for handlebars or spacebars to get better results. Blaze is the template engine; not the template system (if that makes sense.)

How do I populate a bootstrap grid system using handlebars for each command in Meteor.js?

Community
  • 1
  • 1
ChatGPT
  • 5,334
  • 12
  • 50
  • 69
-2

Generically, you need to ensure that your collection is exposed to the template, most likely in a template helper. Then you can iterate the collection items like so:

{{#each templateHelperName}}
<div class="row">
  <div class="col-md-8">{{propertyName1}}</div>
  <div class="col-md-4">{{propertyName1}}</div>
</div>
{{/each}} 

To create a template helper, take a look at the meteor docs; they're quite good.

If this doesn't help, perhaps you can provide some more clarity about what your collection looks like, and how you'd like it displayed. Your code doesn't really give much indication.

Stuart Updegrave
  • 687
  • 5
  • 25
  • thanks for getting back. Well, basically my layout should be n items per row, but since I don't know how many items I could have, it needs to detect when a there are more than 2 items, close the row and start a new row. – rapsli May 30 '14 at 22:03
  • I think I sorted it out. I was under the impression that one row can only have "12" cells and then I have to start a new row, but this does not seem to be the case – rapsli Jul 27 '14 at 19:48
  • @stuart your code it would just output the same value for both propertyName1 tokens as the context is the same within the #each loop. – ChatGPT Jul 28 '14 at 09:21