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() {
    return Posts.findOne(this.params._id);
  }
});

Router.route('/posts/:_id/edit', {
  name: 'postEdit',
  data: function() {
    return Posts.findOne(this.params._id);
  }
});

Router.route('/submit', {name: 'postSubmit'});

Router.route('/:postsLimit?', {
  name: 'postsList',
  waitOn: function() {
    var limit = parseInt(this.params.postsLimit) || 5;
    return Meteor.subscribe('posts', {sort: {submitted: -1}, limit: limit});
  },
  data: function() {
    var limit = parseInt(this.params.postsLimit) || 5;
    return {
      posts: Posts.find({}, {sort: {submitted: -1}, limit: limit})
    };
  }
});

var requireLogin = function() {
  if (! Meteor.user()) {
    if (Meteor.loggingIn()) {
      this.render(this.loadingTemplate);
    } else {
      this.render('accessDenied');
    }
  } else {
    this.next();
  }
};

Router.onBeforeAction('dataNotFound', {only: 'postPage'});
Router.onBeforeAction(requireLogin, {only: 'postSubmit'});

@@ -182,16 +182,495 @@
  %7D%0A%7D);%0A%0A
+PostsListController = RouteController.extend(%7B%0A  template: 'postsList',%0A  increment: 5,%0A  postsLimit: function() %7B%0A    return parseInt(this.params.postsLimit) %7C%7C this.increment;%0A  %7D,%0A  findOptions: function() %7B%0A    return %7B%0A      sort: %7Bsubmitted: -1%7D,%0A      limit: this.postsLimit()%0A    %7D;%0A  %7D,%0A  waitOn: function() %7B%0A    return Meteor.subscribe('posts', this.findOptions());%0A  %7D,%0A  data: function() %7B%0A    return %7B%0A      posts: Posts.find(%7B%7D, this.findOptions())%0A    %7D;%0A  %7D%0A%7D);%0A
 %0ARouter.
@@ -1075,24 +1075,24 @@
 sLimit?', %7B%0A
+
   name: 'pos
@@ -1102,336 +1102,8 @@
 ist'
-,%0A  waitOn: function() %7B%0A    var limit = parseInt(this.params.postsLimit) %7C%7C 5;%0A    return Meteor.subscribe('posts', %7Bsort: %7Bsubmitted: -1%7D, limit: limit%7D);%0A  %7D,%0A  data: function() %7B%0A    var limit = parseInt(this.params.postsLimit) %7C%7C 5;%0A    return %7B%0A      posts: Posts.find(%7B%7D, %7Bsort: %7Bsubmitted: -1%7D, limit: limit%7D)%0A    %7D;%0A  %7D
 %0A%7D);

Refactor postsLists route into a Controller.