What is the \"formal\" way of handling multiple \"pages\" in meteor? I say \"pages\" I\'ve seen people do it a couple of different ways. I\'ve seen people create actual full
There are several ways to handle multiple pages in meteor
using iron router you can create a layout template and inject all other templates inside it using {{> yield}}
. Check the iron-router guide to know more about layout template.
if you do not want to add iron-router you can use {{> Template.dynamic}}
to achieve the same.
{{> Template.dynamic template=template_name }}
template_name
can be changed reactively using a template helper
Meteor.startup(function () {
Session.setDefault("templateName", "index")
});
Template.body.helpers({
template_name: function(){
return Session.get("templateName")
}
});
Template.body.events({
"click .home": function() {
Session.set("templateName", "index");
},
"click .about": function() {
Session.set("templateName", "about");
}
// ..
});
If the Session returns "about" then,
{{> Template.dynamic template="about"}}
which is equivalent to {{> about}}
.