Skip to content

Instantly share code, notes, and snippets.

@kasima
Created November 29, 2012 07:33
Show Gist options
  • Save kasima/4167392 to your computer and use it in GitHub Desktop.
Save kasima/4167392 to your computer and use it in GitHub Desktop.
Meteor.Router with and without session params
Meteor.Router.add({
'/posts': 'posts',
'/posts/:id': function(id) {
Session.set('postId');
return 'post';
},
'/authors/:id': function(id) {
Session.set('authorId', id);
return 'author';
}
});
Template.post.post = function () {
return Posts.findOne(Session.get('postId'));
};
Template.author.author = function () {
return Authors.findOne(Session.get('authorId'));
};
Meteor.Router.add({
'/posts': 'posts',
'/posts/:id': 'post',
'/authors/:id': 'author'
});
Template.post.post = function () {
return Posts.findOne(Session.get('params').id);
};
Template.author.author = function () {
return Authors.findOne(Session.get('params').id);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment