Search code examples
javascriptmeteoriron-router

Having problems with layouts in Iron Router on Meteor 1.2


I just updated my Meteor application to Meteor v.1.2.0.2 and Iron Router v.1.0.12. Iron Router keeps returning this error on the client side: Couldn't find a template named "layout" or "layout". Are you sure you defined it?. Nothing is rendered except for this error. Here's my routes.js file:

Router.configure({
  layoutTemplate: 'layout',
  loadingTemplate: 'loading'
});

Router.route('/', function() {
    if (this.ready) {
      this.render();
    }

    else {
      this.render('loading');
    }
  },
  { name: 'main' } );

Router.route('/new/story', { name: 'newStory' } );

Router.route('/story/:_id', { name: 'viewStory', data: function() {
  return Stories.findOne(this.params._id);
},

waitOn: function () {
  return [Meteor.subscribe("story", this.params._id), Meteor.subscribe("seeds", this.params._id)];
},

onBeforeAction: function() {

    var document = Stories.find({ _id: this.params._id }).fetch();
    if ($.inArray(Meteor.user()._id, document[0].contributors) === -1) {
      this.render('addSeed');
    }

    else {
      this.next();
    }

}  } );

Router.route('/stories', { name: 'viewStories',
  waitOn: function() {
    Meteor.subscribe("stories");
  }
});

Router.route('/story/:_id/new/seed', { name: 'addSeed', data: function() {
  return Seeds.findOne(this.params._id);
}} );

Router.route('/logout', function() {
  Meteor.logout();
  Router.go("main");
});

The layout template looks like this:

<template name="layout">
  {{> nav}}
  {{> yield}}
</template>

I don't understand what's wrong. Please help!


Solution

  • I had same errors after updating to Meteor v.1.2.
    As it turned out the problem was at materialize package. Rollback from 0.97.1 to 0.97.0 version of materialize packcage works for me.