覆盖铁路由器流星中的布局模板

Override layout template in iron-router Meteor

我有一个 meteor 应用程序,使用 iron router 进行导航。我有一个在每个页面上呈现的布局文件。虽然有一个页面我不希望布局文件是displayed/rendered。我敢打赌有一种优雅的方法可以实现这一点,但不幸的是我还没有找到。

Router.configure({
    layoutTemplate: 'layout',
    loadingTemplate: 'loading',
    notFoundTemplate: 'notapage'
});
Router.route('dataNotFound', function() {
    this.render('notapage');
});
Router.route('test/qwerty', function() {
    this.render('abc');
}, {

name: 'abc',
waitOn: function() {
    return [
        Meteor.subscribe('testSubscription')
    ];
}

});

布局文件:

<template name="layout">
<nav class="navbar navbar-default navbar-fixed-top">
    ...
</nav>
    <div class="clearfix"></div>
    <div class="page-container">
        {{>yield}}
    </div>
<div class="page-footer">
    ...
</div>

如果路由等于 abc,我不希望 layout.html 文件是 rendered/displayed。

您可以覆盖单个路由定义上的默认布局文件,请参阅:http://iron-meteor.github.io/iron-router/#layouts

Router.route('/post/:_id', function () {
   this.layout('ApplicationLayout');
});

该文档还介绍了如何将模板渲染到同一布局模板中的不同收益区域。