Search code examples
meteoriron-router

Meteor 1.0: iron-router layout on all pages but one


I have a project that involves a dozen routes, all of which require a navbar and various other pieces that I would like to include in my layout template.

My issue is that I have one and only one page that doesn't need a navbar. I could solve this by taking the navbar out of the layout template and putting the navbar manually in every page that needs it, but that doesn't seem like an elegant solution.

Is there a way to exclude a particular route from including a piece of the layout template?


Solution

  • Why not assigning this particular route another layout who doesn't include the navbar then ?

    HTML

    <template name="mainLayout">
      {{> navbar}}
      {{> yield}}
      {{> footer}}
    </template>
    
    <template name="withoutNavbarLayout">
      {{> yield}}
      {{> footer}}
    </template>
    

    JS

    Router.configure({
      layoutTemplate:"mainLayout"
    });
    
    Router.route("/withoutNavbar",{
      layoutTemplate:"withoutNavbarLayout"
    });