Reputation: 2478
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?
Upvotes: 1
Views: 252
Reputation: 229
Here is another simple solution to the problem.
Just set the layoutTemplate to null for the specified page you want to exclude layout. For example, here we will remove the layout and navigation for the login page:
Router.route('login', {
layoutTemplate: '' //set the layoutTemplate to null for the login route
});
Hope it helps.
Upvotes: 0
Reputation: 22696
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"
});
Upvotes: 3