Вопрос

Thanks again for this awesome router. I'm having an issue with yield not yielding where it should. Like most errors, this one is probably caused somewhere between the chair and the keyboard so I'd appreciate your help!

My Template html is quite simple.

<body>
  {{> layout}}
</body>

<template name='layout>
<!--wrapper tags -->
  {{> nav}}
   <!--more wrapper tags -->  
     {{yield}}
   <!--close wrapper tags -->  
   {{> footer}}
 <!--close wrapper tags -->  
</template>

When this renders, I see (in order): NAV > FOOTER > NAV > YIELD > FOOTER

I tried putting all the wrappers and {{>nav}} and {{>footer}} into the main body tag, leaving only {{yield}} in the layout template. When I do that, I get NAV > FOOTER > YIELD.

In both cases, my router js is identical:

if (Meteor.isClient) {

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

Router.map(function () {
  this.route('home', {
    path: '/',
    template: 'home',
    after: function () {
      addLabel(this.path);
    }
  })
//more routes
});
}

I'm sure it's something silly I've done but would appreciate any help you might offer.

Thanks in advance, db

Это было полезно?

Решение

Remove the {{> layout}} from body tag.

<body>
  <!-- no template here, router will add layout automatically -->
</body>

<template name='layout'>
<!--wrapper tags -->
  {{> nav}}
   <!--more wrapper tags -->  
     {{yield}}
   <!--close wrapper tags -->  
   {{> footer}}
 <!--close wrapper tags -->  
</template>

And you are missing ' in < template name='layout>...

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top