title: I can use app.locals directly in templates but not res.locals
body: <p>In my Express application, I'm able to set <code>app.locals</code> and use them directly in my templates (rendered using <a href="https://github.com/ericf/express-handlebars" rel="nofollow">express-handlebars</a>). However, when I set <code>res.locals</code> in middleware, they are not available unless I pass them in. Am I doing something wrong?</p>
  
  <p><strong>Server</strong></p>
  
  <pre><code>app.locals.foo = "foo";
  app.use(function(req, res, next) {
    res.locals.bar = "bar";
    next();
  });
  </code></pre>
  
  <p><strong>Template</strong></p>
  
  <pre><code>{{foo}} {{bar}}
  </code></pre>
  
  <p><strong>Test 1</strong></p>
  
  <pre><code>app.get("/", function(req, res) {
    app.render("template.html", {}, function(error, html) {
      res.send(html);
    });
  });
  </code></pre>
  
  <p><em>Result</em></p>
  
  <pre><code>foo
  </code></pre>
  
  <p><strong>Test 2</strong></p>
  
  <pre><code>app.get("/", function(req, res) {
    app.render("template.html", {bar: res.locals.bar}, function(error, html) {
      res.send(html);
    });
  });
  </code></pre>
  
  <p><em>Result</em></p>
  
  <pre><code>foo bar
  </code></pre>