title: Meteor Page Re-rendering with Backbone router
body: <p>I'm trying to create a blog application with Meteor. In this blog there is the main page where visitors will simply read the posts, and another section where it would be the 'admin' panel where I can edit posts. I'm trying to utilize the handlebars Template helpers but I'm not sure where I got it wrong. I'm also a amateur developer and trying to learn the Meteor framework better. My code is as such:</p>
  
  <p><strong>blog.html</strong></p>
  
  <pre><code>&lt;head&gt;
    &lt;title&gt;Jeff Lam Tian Hung&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
    &lt;h1&gt;Jeff Lam Tian Hung&lt;/h1&gt;
    &lt;a href="/" class="main"&gt;Main Page&lt;/a&gt;
    &lt;a href="/admin" class="admin"&gt;Admin&lt;/a&gt;
    {{&gt; content}}
  &lt;/body&gt;
  
  &lt;template name="content"&gt;
    {{#if currentPage "blog"}}
      {{#each posts}}
        &lt;h2&gt;{{Title}}&lt;/h2&gt;
        &lt;p&gt;{{Body}}&lt;/p&gt;
      {{/each}}
    {{/if}}
  
    {{#if currentPage "admin"}}
      &lt;h2&gt;{{admin}}&lt;/h2&gt;
    {{/if}}
  &lt;/template&gt;
  </code></pre>
  
  <p><strong>blog.js</strong></p>
  
  <pre><code>// Declaration of Collections
  Posts = new Meteor.Collection("Posts");
  
  // Helper variable is for pages
  // TODO: changing this var will change the
  // page but now how to rerender the page?
  var page = "blog";
  
  // Declaration of Template Reactivity Variables
  Template.content.currentPage = function (type) {
    return page === type;
  };
  Template.content.posts = function () {
    return Posts.find({}, {sort: {Date: 1}});
  };
  Template.content.admin = function () {
    return "This will render admin section";
  };
  
  // Router for Pages
  var Router = Backbone.Router.extend({
    routes: {
      "":      "main",
      "admin": "admin"
    },
    main: function () {
      page = "blog";
    },
    admin: function () {
      page = "admin";
    }
  });
  
  var BlogRouter = new Router;
  
  Meteor.startup(function () {
    Backbone.history.start({pushState: true});
  });
  </code></pre>
  
  <p><strong>publish.js (server-side code only)</strong></p>
  
  <pre><code>Posts = new Meteor.Collection("Posts");
  </code></pre>
  
  <p>The page would render the blog posts with the above code, but when I access localhost:3000/admin the page variable is set to 'admin' as coded, but the page/template doesn't re-render itself to display the 'Admin' text. </p>
  
  <p>However, if I were to set the var page = 'admin' and refresh the app, the page rerenders the admin message just fine. I'm not sure if I'm using the handlebars template helpers correctly to do this sort of 'one-page template refresh with routing'. Thanks for any help!</p>