Global properties in Express & Handlebars
问题 I'm using Handlebars (using express3-handlebars) for templates and Passport for authentication in a NodeJS app. All is working great but I wondered if there is a way to pass the req.user object created by Passport to Handlebars globally. So my header partial might look something like this: <header> <h1>My Title</h1> {{#if user}} <p>Hello {{user.name}}</p> {{else}} <p>Please <a href='/login'>Log In</a></p> {{/if}} </header> As it stands I have to pass the user object explicitly with every page