Skip to content

Instantly share code, notes, and snippets.

@Streemo
Created October 25, 2014 20:09
Show Gist options
  • Save Streemo/a0acf9f140fa3d341a5f to your computer and use it in GitHub Desktop.
Save Streemo/a0acf9f140fa3d341a5f to your computer and use it in GitHub Desktop.
Router.configure({
layoutTemplate: 'ApplicationLayout',
notFoundTemplate: 'notFound',
yieldTemplates: {
'header': {to: 'heading'}
}
});
var requireLogin = function(pause){
if (!Meteor.userId()){
if (Meteor.loggingIn()){
this.render('loading'); //doesnt exist, but thats ok.
} 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