如何在 Meteor 中将模板拆分为单独的文件
How to split templates into separate files in Meteor
我正在使用 Meteor.js 和 router.js(包)来呈现我网站的其他页面。但是,我所有的模板(其他页面)都在一个 html 文件中。如何将我的模板拆分为不同的 html 文件并仍然使用 router.js?
模板的一个示例路由器配置是:
Router.route('/events',
function(){
this.render('eventsPage');
},
{
onAfterAction: function() {
document.title = 'Events';
}
});
其中 /events 是与模板 'eventsPage' 关联的 url。如何将 eventsPage 模板放入单独的 html 文件中?
提前致谢。
您可以将每个模板放在单独的文件中,Meteor 会检测您所有的 html 代码。
HTML files in a Meteor application are treated quite a bit differently from a server-side framework. Meteor scans all the HTML files in your directory for three top-level elements: , , and . The head and body sections are separately concatenated into a single head and body, which are transmitted to the client on initial page load.
阅读更多:http://docs.meteor.com/#/full/whatismeteor
所以您的 HTML 文件结构主要取决于您的偏好。
您还应该看看:
http://meteortips.com/first-meteor-tutorial/structure/
我正在使用 Meteor.js 和 router.js(包)来呈现我网站的其他页面。但是,我所有的模板(其他页面)都在一个 html 文件中。如何将我的模板拆分为不同的 html 文件并仍然使用 router.js?
模板的一个示例路由器配置是:
Router.route('/events',
function(){
this.render('eventsPage');
},
{
onAfterAction: function() {
document.title = 'Events';
}
});
其中 /events 是与模板 'eventsPage' 关联的 url。如何将 eventsPage 模板放入单独的 html 文件中?
提前致谢。
您可以将每个模板放在单独的文件中,Meteor 会检测您所有的 html 代码。
HTML files in a Meteor application are treated quite a bit differently from a server-side framework. Meteor scans all the HTML files in your directory for three top-level elements: , , and . The head and body sections are separately concatenated into a single head and body, which are transmitted to the client on initial page load.
阅读更多:http://docs.meteor.com/#/full/whatismeteor
所以您的 HTML 文件结构主要取决于您的偏好。
您还应该看看: http://meteortips.com/first-meteor-tutorial/structure/