Last active
August 29, 2015 14:22
-
-
Save geekforbrains/3292d647ca418ec28682 to your computer and use it in GitHub Desktop.
Meteor router brainstorm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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