Created
October 25, 2014 20:31
-
-
Save Streemo/ff6743d8f066fa7e86bf to your computer and use it in GitHub Desktop.
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.configure({ | |
layoutTemplate: 'ApplicationLayout', | |
notFoundTemplate: 'notFound', | |
yieldTemplates: { | |
'header': {to: 'heading'} | |
} | |
}); | |
var requireLogin = function(pause){ | |
if (!Meteor.userId()){ | |
if (Meteor.loggingIn()){ | |
this.render('loading'); | |
} else { | |
this.render('accessDenied'); | |
} | |
pause(); | |
} | |
} | |
Router.map(function(){ | |
this.route('posts', { | |
path: '/', | |
template: 'postsList', | |
}); | |
this.route('detail', { | |
path: '/posts/:_id', //this is where we get the url variables. | |
template: 'postPage', //we can use data: to move these around in | |
data: function(){ //our app, e.g. to Template context. | |
return { | |
currentPost: Posts.findOne({_id: this.params._id}), | |
}; | |
} | |
}); | |
this.route('submit', { | |
path: '/submit', | |
template: 'postSubmit', | |
onBeforeAction: requireLogin | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment