Advertisement
Guest User

Untitled

a guest
Jan 25th, 2015
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. Router.route('/post/:_id', {
  2. // The name of the route.
  3. // Used to reference the route in path helpers and to find a default template
  4. // for the route if none is provided in the "template" option. If no name is
  5. // provided, the router guesses a name based on the path '/post/:_id'
  6. name: 'post.show',
  7.  
  8. // To support legacy versions of Iron.Router you can provide an explicit path
  9. // as an option, in case the first parameter is actually a route name.
  10. // However, it is recommended to provide the path as the first parameter of the
  11. // route function.
  12. path: '/post/:_id',
  13.  
  14. // If we want to provide a specific RouteController instead of an anonymous
  15. // one we can do that here. See the Route Controller section for more info.
  16. controller: 'CustomController',
  17.  
  18. // If the template name is different from the route name you can specify it
  19. // explicitly here.
  20. template: 'Post',
  21.  
  22. // A layout template to be used with this route.
  23. // If there is no layout provided, a default layout will
  24. // be used.
  25. layoutTemplate: 'ApplicationLayout',
  26.  
  27. // A declarative way of providing templates for each yield region
  28. // in the layout
  29. yieldRegions: {
  30. 'MyAside': {to: 'aside'},
  31. 'MyFooter': {to: 'footer'}
  32. },
  33.  
  34. // a place to put your subscriptions
  35. subscriptions: function() {
  36. this.subscribe('items');
  37.  
  38. // add the subscription to the waitlist
  39. this.subscribe('item', this.params._id).wait();
  40. },
  41.  
  42. // Subscriptions or other things we want to "wait" on. This also
  43. // automatically uses the loading hook. That's the only difference between
  44. // this option and the subscriptions option above.
  45. waitOn: function () {
  46. return Meteor.subscribe('post', this.params._id);
  47. },
  48.  
  49. // A data function that can be used to automatically set the data context for
  50. // our layout. This function can also be used by hooks and plugins. For
  51. // example, the "dataNotFound" plugin calls this function to see if it
  52. // returns a null value, and if so, renders the not found template.
  53. data: function () {
  54. return Posts.findOne({_id: this.params._id});
  55. },
  56.  
  57. // You can provide any of the hook options described below in the "Using
  58. // Hooks" section.
  59. onRun: function () {},
  60. onRerun: function () {},
  61. onBeforeAction: function () {},
  62. onAfterAction: function () {},
  63. onStop: function () {},
  64.  
  65. // The same thing as providing a function as the second parameter. You can
  66. // also provide a string action name here which will be looked up on a Controller
  67. // when the route runs. More on Controllers later. Note, the action function
  68. // is optional. By default a route will render its template, layout and
  69. // regions automatically.
  70. // Example:
  71. // action: 'myActionFunction'
  72. action: function () {
  73. // render all templates and regions for this route
  74. this.render();
  75. }
  76. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement