iron-meteor / iron-router

A client and server side router designed specifically for Meteor.
MIT License
1.98k stars 413 forks source link

Route loads wrong template #1573

Closed tomtom87 closed 7 years ago

tomtom87 commented 7 years ago

I am defining several routes and layouts. Everything is working fine in my app, untill I added a new route for terms, it will always only display the layout for the about us section. No matter how I configure this page.

Router.coffee

Router.map ->
  @route "home",
    path: "/",
    layoutTemplate: "homeLayout",
    waitOn: ->
      [
        subs.subscribe 'companies'
      ]

  @route "terms",
    path: "/terms",
    layoutTemplate: "termsConditionLayout"

  @route "supplierInfo",
    path: "/supplier-info",
    layoutTemplate: "supplierLayout"

  @route "about",
    path: "/about",
    layoutTemplate: "aboutLayout"

Templates:

<template name="termsConditionLayout">
    <div class="layout home-layout">
    <div class="layout home-layout">
      {{> terms }}
    </div>
  </div>
  {{> footer}}
</template>
<template name="aboutLayout">
    <div class="layout home-layout">
    <div class="layout home-layout">
      {{> yield }}
    </div>
  </div>
  {{> footer}}
</template>

No matter what happens the aboutLayout will display in place of the termsLayout when I am on the /terms URL path. Why? I really need to fix this.

honwlt commented 7 years ago

Yield is the problem....

either have

<template name="aboutLayout">
    <div class="layout home-layout">
    <div class="layout home-layout">
      {{> about }}
    </div>
  </div>
  {{> footer}}
</template>

OR

<template name="termsConditionLayout">
    <div class="layout home-layout">
    <div class="layout home-layout">
      {{> yield }}
    </div>
  </div>
  {{> footer}}
</template>
tomtom87 commented 7 years ago

Ah ok must specify the template name for this section got you