Search code examples
javascriptmeteoriron-router

How to not display the default template in one of the routes in Meteor Iron-Router?


I'm trying to render my home template without the default layoutTemplate. Iron-router Guide shows I need to use Router.onBeforeAction. I just can't figure out how exactly to implement it.

Router.configure({
 layoutTemplate: 'navbar'

}

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

Solution

  • You can override the default layout template by calling this.layout(); in your route. Either you supply a different layout template, e.g. this.layout('homeLayout'); or you just leave the arguments empty.

    For example:

    Router.route('/', function () {
        this.layout();
        this.render('home');
    }, {name: 'home'});