For routing you need to use BackboneJS ( Backbone Router ). With this code, the session variable 'page_type' will tell you if you have the wrong URL.
var BackboneRouter = Backbone.Router.extend({ routes: { "/": "default", ":error": "list" }, default: function () { Session.set("page_type", "default"); }, error: function () { Session.set("page_type", "error"); } }); Router = new BackboneRouter; Meteor.startup(function () { Backbone.history.start({pushState: true}); });
Now you can use "page_type" to tell the template engine which template to load.
Template.tmp.route = function () { if (Session.get("page_type") == "default") { return true; } else { return false; } <template name="tmp"> {{#if route}} {{> default}} {{else}} {{> error}} {{/if}} </template>
fraherm Jul 16 '12 at 22:12 2012-07-16 22:12
source share