mikeric/rivets — pull request #221 by ZMan9854 (2013-10-24 09:10:53+00:00)
Title: Pass local models into component build method

This is useful when a component utilizes a dynamic property of a model. Example:

```
// Markup

// Component
rivets.components.mycomponent = {
attributes: [],

build: function(models) {
var template = models.car.template; // 'my-template-key'
return App.templates[template];
}
};

// Car model
var car = {
template: 'my-template-key'
};

// Bind the view
rivets.bind($('#my-view'), { thecar: car });
```

A more elegant approach might be to allow the attributes to be dynamic, but I didn't include an attempt at this in the pull request:

```
// Markup

// Component
rivets.components.mycomponent = {
attributes: ['template'],

build: function() {
return App.templates[this.template];
}
};

// Car model
var car = {
template: 'my-template-key'
};

// Bind the view
rivets.bind($('#my-view'), { thecar: car });
```

My use case is a looped set of models where each model corresponds to a unique template.