I found the same problem. When the code gets bigger, it's hard to keep the code clean.
Here is my approach to this problem:
I share different html pages as I would with a different web map. There is index.html where I store the html root page. And then for each large functional part I create a different template and put it in one different html. The meteor then unites them all. Finally, I create a session variable called operation , where I determine what to show each time.
Here is a simple example
index.html
<head> <title>My app name</title> </head> <body> {{> splash}} {{> user}} {{> debates}} </body>
then in splash.html
<template name="splash"> {{#if showSplash}} ... your splash html code goes here... {{/if}} </template>
then in user.html
<template name="user"> {{#if showUser}} ... your user html code goes here... {{/if}} </template>
etc.
In javascript code, I check when to print each template using the Session variable, for example:
Template.splash.showSplash = function(){ return Session.get("operation") == 'showSplash'; }
Finally, the Backbone Router manages this session variable.
var DebateRouter = Backbone.Router.extend({ routes: { "": "showSplash", "user/:userId": "showUser", "showDebates": "showDebates", // ... }, splash: function () { Session.set('operation', 'showSplash'); this.navigate('/'); }, user: function (userId) { Session.set('operation', 'showUser'); this.navigate('user/'+userId); }, // etc... });
I hope this diagram is useful for other Meteor developers.
Carlos Barcelona Jan 26 '13 at 10:38 2013-01-26 10:38
source share