2017-04-13 51 views
0

你好,我正在使用流星&布拉澤。流星和火焰模板的子部分

我的路線是這樣的:

FlowRouter.route('/software', { 
    name: 'software', 
    action(params, queryParams) 
    { 
     BlazeLayout.render('App_body', {main_content: 'software_page'}); 
    } 
}); 

而在App_body我使用main_content(持有模板的名稱)是這樣的:

{{> Template.dynamic template=main_content}} 

但現在我意識到,我喜歡在App_body中插入的不僅僅是「main_content」。有沒有辦法爲每個模板定義子部分,並引用它們,因爲這代表了我的邏輯連接。

回答

1

有在blaze-layout自述的頂部使​​用動態模板的例子:

HTML:

<template name="layout1"> 
    {{> Template.dynamic template=top}} 
    {{> Template.dynamic template=main}} 
</template> 

<template name="header"> 
    <h1>This is the header</h1> 
</template> 

<template name="postList"> 
    <h2>This is the postList area.</h2> 
</template> 

<template name="singlePost"> 
    <h2>This is the singlePost area.</h2> 
</template> 

現在可以呈現佈局,同時在多個模板名稱中是第二個參數餵養每個鍵指定模板名稱的對象。

JS:

BlazeLayout.render('layout1', { top: "header", main: "postList" });