router.js 826 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /**
  2. * @file
  3. *
  4. *
  5. * User: marand
  6. * Date: 30/08/15
  7. * Time: 16:47
  8. */
  9. Router.configure({
  10. layoutTemplate: "layout",
  11. loadingTemplate: "loading",
  12. notFoundTemplate: "notFound",
  13. waitOn: function () {
  14. return Meteor.subscribe('posts');
  15. }
  16. });
  17. // C'est un nom de route, pas un nom de template. Mais IR le prend comme nom de template par défaut.
  18. Router.route('/', {
  19. name: 'postsList'
  20. });
  21. Router.route('/posts/:_id', {
  22. name: 'postPage',
  23. data: function () {
  24. // "this" is the matched route.
  25. return Posts.findOne(this.params._id);
  26. }
  27. });
  28. Router.route('/submit', {
  29. name: 'postSubmit'
  30. });
  31. // Faire une 404 si la page matche la route postPage, mais pas son argument.
  32. // Déclenché pour toute valeur "falsy" (null, false, undefined, empty).
  33. Router.onBeforeAction('dataNotFound', {
  34. only: 'postPage'
  35. });