Iron-Router Wait-On Don't Expect Yield

I noticed that my router definition is not waiting for the subscription for yieldTemplates to complete, but is waiting for the main template. Is there a way for the yield patterns to also be expected on waitOn

?

Route:

Router.route('/', {
 template : 'main',
 layoutTemplate: 'appLayout',
 waitOn: function () {
    // return one handle, a function, or an array
    return [Meteor.subscribe('userInformation'), Meteor.subscribe('projects')];
 },
 data: function () {
    return Meteor.user();
 },
 action: function () {
    if (this.ready()) {
        this.render();
    } else {
        this.render('login');
    }
 },
 yieldTemplates: {
    'dash': {to: 'side'}
 }
});

      

I am using the data attribute on my template dash and initially it returns undefined. Thanks to

+3


source to share


2 answers


I believe the syntax is outdated, the docs use this syntax to define output templates:

this.render('dash', {to: 'side'});

      



Never had a problem waitOn

using this syntax, let it go?

+1


source


Instead of using it yieldTemplates

in a router, try transforming the content in the layout area from the main template using contentFor

template / helper.

Remove yieldTemplates

from first Router.route

. Then add the template {{> contentFor}}

to your main template:

<template name="main">
    {{> contentFor region="side" template="dash"}}
</template>

      

Alternatively, you can use the helper version contentFor

:

<template name="main">
    {{#contentFor 'side'}}
        {{> dash}}
        <!-- and anything else you want to include -->
    {{/contentFor}}
</template>

      



Here is a MeteorPad that demonstrates it works: http://meteorpad.com/pad/QCo3JsFLr6R438izF/Leaderboard

More details contentFor

can be found in the iron-router docs:

https://github.com/iron-meteor/iron-router/blob/devel/Guide.md#rendering-templates-into-regions-using-contentfor .

Also, yieldTemplates

now superseded yieldRegions

in later versions of Iron-Router (I'm using 1.0.7), but the templates referenced here still don't wait for a feature waitOn()

.

+1


source







All Articles