title: Using functions with express.js "locals"
body: <p>Coming from a Rails/Sinatra background, I won't feel at home without being able to use helper functions in my view files, however achieving this in express.js has proven quite difficult.</p>
  
  <p>You can set <a href="http://expressjs.com/api#app.locals" rel="nofollow">locals</a> to be automatically included like this...</p>
  
  <pre><code>app.set("name", "Adam's App");
  </code></pre>
  
  <p>Then in the view file, accessing the variable is as simple as:</p>
  
  <pre><code>&lt;!-- views/template.ejs --&gt;
  &lt;title&gt;&lt;%= settings.name %&gt;&lt;/title&gt;
  </code></pre>
  
  <p>But what about for functions? What if I want to have a <code>date_helper</code> function in my views? I tried setting it like you would a variable...</p>
  
  <pre><code>app.set("date_helper", function(timestamp){ ... });
  </code></pre>
  
  <p>...however calling <code>&lt;%= settings.date_helper %&gt;</code> won't execute the function (obviously), let alone enable me to pass the <code>timestamp</code> argument to it.</p>
  
  <p>Am I going about this the right way?</p>