Is there any way to implement the following logic with Meteor Spacebars?
Pseudo-code, a mix of Meteor and Django's forloop:
{{#each jobs}}
{{>jobItem }}
{#if not forloop.last }}<hr>{{/if}}
{{/each}}
Unforunately {{each}}
doesn't do index. So you kind of have to pass back more info to the item to get it the info you would need. For instance this can put the index into your return object as another field.
var returnArray = _.map(divisions, function(item, key) {
return _.extend(item, {
"index": key
});
});
Considering you just want the last one though, you might just want to append one attribute to the last one in your jobs. Create a helper function that just returns something like
return _.extend(_.last(Jobs.find().fetch(), {"last": true})
Then you can just have a {{#if last}}{{else}}<hr>{{/if}}
. This way all the items that don't have the value get the hr, and your one that does have a last value, won't.
You could probably also take care of it in CSS.
hr:last-of-type { display: none }
You might have to double check the syntax on that.