Skip to content

Instantly share code, notes, and snippets.

@geekforbrains
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geekforbrains/3292d647ca418ec28682 to your computer and use it in GitHub Desktop.
Save geekforbrains/3292d647ca418ec28682 to your computer and use it in GitHub Desktop.
Meteor router brainstorm
// Router with no optoins
SiteRouter = new Router();
SiteRouter.route('/', {name: 'site.index'});
SiteRouter.route('/page/:pageId', {
name: 'site.page', // automatically looks for a template named "site.page" and loads it
subs: Meteor.subscribe('pageById', this.params.pageId)
});
// Define a custom router
AdminRouter = new Router({
root: '/admin', // path to prepend to all admin routes
subs: [ // subscriptions to be used on all admin routes
Meteor.subscribe('users'),
Meteor.subscribe('songs')
]
});
// Inherits `users` and `songs` subscriptions but also defines its own `reports` sub
AdminRouter.route('/dashboard', {
name: 'admin.dashboard',
subs: Meteor.subscribe('reports')
});
// Inherits `users` and `songs` subscriptions
AdminRouter.route('/users', {
name: 'admin.users'
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment