| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 | Router.configure({  layoutTemplate: 'layout',  loadingTemplate: 'loading',  notFoundTemplate: 'notFound',  waitOn: function () {    return [      Meteor.subscribe('notifications')    ];  }});Router.route('/posts/:_id', {  name: 'postPage',  waitOn: function () {    return Meteor.subscribe('comments', this.params._id);  },  data: function () {    // "this" is the matched route.    return Posts.findOne(this.params._id);  }});Router.route('/posts/:_id/edit', {  name: 'postEdit',  waitOn: function () {    return Meteor.subscribe('singlePost', this.params._id);  },  data: function () {    // "this" is the matched route.    return Posts.findOne(this.params._id);  }});Router.route('/submit', {  name: 'postSubmit'});// C'est un nom de route, pas un nom de template. Mais IR le prend comme nom de// template par défaut.Router.route('/:postLimit?', {  name: 'postsList',  waitOn: function () {    var limit = parseInt(this.params.postLimit) || 5;    return Meteor.subscribe('posts', {      sort: { submitted: -1 },      limit: limit    });  },  data: function () {    var limit = parseInt(this.params.postLimit) || 5;    return {      posts: Posts.find({}, {        sort: { submitted: -1 },        limit: limit      })    };  }});var requireLogin = function () {  if (!Meteor.user()) {    if (Meteor.loggingIn()) {      // Défini dans Router.configure().      this.render(this.loadingTemplate);    } else {      this.render('accessDenied');    }  } else {    this.next();  }};// Faire une 404 si la page matche la route postPage, mais pas son argument.// Déclenché pour toute valeur "falsy" (null, false, undefined, empty).Router.onBeforeAction('dataNotFound', {  only: 'postPage'});// Appliquer le contrôle d'accès à la route postSubmit.Router.onBeforeAction(requireLogin, {  only: 'postSubmit'});
 |