我目前正在做一个meteorjs网站。但是,我有一个正确呈现网站内容的问题。(因为我有一个固定的侧边栏)。
//layout.html
<head>
<title>App</title>
</head>
<body>
//render helper
{{renderPage layout}}
</body>
//路由.js
Meteor.Router.add({
'/': 'index',
'/admin': 'admin',
'/search': 'search',
'/contact': 'contact',
'/login':'login',
'/logout':'logout',
'/registration': 'registration',
'/admin/listUser': 'listUser',
'/admin/addUser': 'addUser',
'/admin/editUser': 'editUser',
'/admin/delUser': 'delUser',
'/admin/listPost': 'listPost',
'/admin/addPost': 'addPost',
'/admin/editPost': 'editPost',
'/admin/delPost': 'delPost',
'/admin/viewPost': 'viewPost',
'/admin/modPost': 'modPost',
'/admin/listLoc': 'listLoc',
'/admin/addLoc': 'addLoc',
'/admin/delLoc': 'delLoc',
})
// to determin which page to render
Template.body.helpers({
layout: function() {
switch (Meteor.Router.page()) {
case 'index':
return 'index';
case 'admin':
return 'admin';
case 'login':
return 'login';
case 'logout':
return 'logout';
case 'registration':
return 'registration';
case 'search':
return 'search';
case 'contact':
return 'contact';
default:
return 'index';
}
}
});
管理员.html
//sidebar
<template name="adminSide">
<ul class="nav nav-list">
<li class="nav-header">User Management</li>
<li><a href="/admin/listUser" id="linkValue">List Users</a></li>
<li class="nav-header">Posting Management</li>
<li><a href="/admin/listPost">List Posting</a></li>
<li><a href="/admin/addPost">Add New Posting</a></li>
<li><a href="/admin/modPost">Moderate Posting</a></li>
<li class="nav-header">Location Management</li>
<li><a href="/admin/listLoc">List Locations</a></li>
<li><a href="/admin/addLoc">Add New Locations</a></li>
<li class="divider"></li>
<li><a href="/logout">Log Out</a></li>
</ul>
</template>
//landing page
<template name="adminLand">
<div class="page-header">
<h1>Welcome to the Admin Panel!</h1>
</div>
<p class="lead">To begin, click on any link on the left.</p>
</template>
//page to render if click on sidebar
<template name="listUser">
</template>
<template name="admin">
{{> navigationAdm}}
<div class="container">
<div class="row">
<div class="span3">
{{>adminSide}}
</div>
<div class="span9">
//how do I make this render another template when the sidebar is clicked?
{{renderPage}}
</div>
</div>
<hr>
{{>footer}}
</div>
</template>
我正在使用 Meteorite 的路由器。提前致谢!