Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Layout 使用meteor路由器的布局_Layout_Meteor - Fatal编程技术网

Layout 使用meteor路由器的布局

Layout 使用meteor路由器的布局,layout,meteor,Layout,Meteor,从这里的讨论中, 我试图在现有的{{renderPage}中显示一个模板 我的用例:我有一个非常简单的高级主体模板 <template name="body"> {{> header}} {{> notifications}} <div class="content" id="content"> <div id="main-content"> {{{renderPage}}}

从这里的讨论中,

我试图在现有的{{renderPage}中显示一个模板

我的用例:我有一个非常简单的高级主体模板

<template name="body">
    {{> header}}
    {{> notifications}}

    <div class="content" id="content">
        <div id="main-content">

            {{{renderPage}}}

        </div>
    </div>
    {{> footer}}

</template>
路由将找到模板“home”,并用该模板替换renderPage。我现在想扩展它,看看是否可以将路由模板放置在特定的div中

例如,在my home.html模板中:

<template name="home">
        {{#if isAdmin}}
                <h1>student</h1>
        {{/if}}
        <div id="inner_home">
                  {{renderPage innerHome}}
         </div>
</template>
如果有人有更好的方法,请告诉我。

当然

client.js home.js home.html

{{{#如果是isAdmin}
学生
{{/if}
{{{#如果homeTemplateTools}}
{{>家庭工具}
{{/if}
{{#如果homeTemplateAdmin}
{{>homeAdmin}
{{/if}

是否有人使用会话仅更新部分内容。先生,感谢您的详细解释。这很有效。我唯一担心的是,随着My home.html内部模板级别的增加,这会变得非常无结构。例如,如果我有一个内部的_home2,我必须不断地设置和检查会话以显示模板。我想这会起作用的
<template name="home">
        {{#if isAdmin}}
                <h1>student</h1>
        {{/if}}
        <div id="inner_home">
                  {{renderPage innerHome}}
         </div>
</template>
 var foundTemplate = _.template($('#item-template').html())
  $('#div_example').html(foundTemplate); //
Meteor.Router.add({
  '/home/tools': function() {
    Session.set("homeTemplate", "tools");
    return 'home';
  },
  '/home/admin': function() {
    Session.set("homeTemplate", "admin");
    return 'home';
  }
});
Template.home.homeTemplateTools = function() {
    return Session.equal("homeTemplate", "tools");
};

Template.home.homeTemplateAdmin = function() {
    return Session.equal("homeTemplate", "admin");
};
<template name="home">
    {{#if isAdmin}}
            <h1>student</h1>
    {{/if}}
    <div id="inner_home">
    {{#if homeTemplateTools}}
      {{> homeTools}}
    {{/if}}
    {{#if homeTemplateAdmin}}
      {{> homeAdmin}}
    {{/if}}
    </div>
</template>