Skip to content

Instantly share code, notes, and snippets.

@julianlconnor
Last active December 21, 2015 03:19
Show Gist options
  • Save julianlconnor/6241532 to your computer and use it in GitHub Desktop.
Save julianlconnor/6241532 to your computer and use it in GitHub Desktop.
Passing multiple models and collections to a view via Rendr
// controller
module.exports = {
index: function(params, callback) {
var spec = {
posts: { collection: 'Posts', params: params },
feed: { collection: 'Feed', params: params },
user: { model: 'User', params: params, ensureKeys: ['name'] },
session: { model: 'Session', params: params }
};
this.app.fetch(spec, function(err, result) {
callback(err, result);
});
}
};
// view
var BaseView = require('../base');
module.exports = BaseView.extend({
className: 'home_index_view',
postInitialize: function() {
console.log(this.options.posts);
console.log(this.options.feed);
console.log(this.options.user);
console.log(this.options.session);
}
});
module.exports.id = 'home/index';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment