簡體   English   中英

帶有流星和鐵路由器的Yield模板

[英]Yield Templates with meteor and iron router

我正在使用IR的新blaze-integration分支,並對現有應用程序進行了必要的更改。 我在我的一個模板中有一個yield區域:

<div>
        {{> yield region='signup-detail'}}
</div>

我想使用yieldTemplates在路由配置中設置此區域。 我的路線配置如下:

this.route('signUpInfo', {
        path: '/sign-up',
        template: 'signUp-form',
        yieldTemplates: _.extend({}, mainYieldTemplates, {
            'information': {to: 'signup-detail'}
        })
    });

mainYieldTemplates = {
    'footer': { to: 'footer' },
    'header': {to: 'header'}
};

我的模板“信息”未呈現為signup-detail 只有新的鯊魚分支和IR火焰發生,使用Yield模板有什么變化?

頁腳和標題模板設置正確。

編輯:模板布局

<template name="basicLayout">

    {{> yield region='header'}}
    <div class="container">
        <div class="row">
            <div class="col-md-12 col-centered padding-top-four-em">
                {{> yield}}
            </div>
        </div>
        <hr>
        <footer>
            {{> yield region='footer'}}
        </footer>
    </div>
</template>

編輯2:SignUp表單模板

<template name="signUp-form">
    <div class="col-md-12 signup-container">
        {{>signUpSideBar}}
        <div class="col-md-9 signup-content gray-border-box">
            {{> yield region='signup-detail'}}
        </div>
    </div>
</template>

注意:signUp-form模板具有區域signup-detail 這是我的路由signUpInfo需要將information模板呈現給該區域的地方。 這曾經在火焰整合之前在IR中工作。

我不知道它是一種完美的渲染方式。但它對我有用

route.js

Router.route('/', function () {

    // use the template named ApplicationLayout for our layout
    this.layout('ApplicationLayout');

    // render the Post template into the "main" region
    // {{> yield}}
    this.render('Post');

    // render the PostAside template into the yield region named "aside" 
    // {{> yield "aside"}}
    this.render('PostAside', {to: 'aside'});

    // render the PostFooter template into the yield region named  "footer" 
   // {{> yield "footer"}}
   this.render('PostFooter', {to: 'footer'});
});

ApplicationLayout.html

<template name="ApplicationLayout">
    <header>
        <h1>{{title}}</h1>
    </header>

    <aside>
        {{> yield "aside"}}
    </aside>

    <article>
        {{> yield}}
    </article>

    <footer>
        {{> yield "footer"}}
    </footer>
</template>

main.html中

<template name="Post">
    <p>
        {{post_content}}
    </p>
</template>

<template name="PostFooter">
    Some post specific footer content.
</template>

<template name="PostAside">
    Some post specific aside content.
</template>

看起來您的{{> yield region='signup-detail'}}不在您的yieldTemplate中,因此路由器無法找到注冊詳細信息區域來插入您的“信息”模板。

您的yieldTemplate中的{{> yield}}呈現'signUp-form'(來自您的template:路線中的分配)。

如果您的“注冊詳細信息”模板是“signUp-form”中的模板,請使用{{> signup-detail}}

如果您希望在多個模板中重復使用“注冊詳細信息”作為layoutTemplate的一部分,請將{{> yield region='signup-detail'}}到yieldTemplate。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM