Once a user has logged in, I want to display their username in the header, which is currently part of layout.jade
. Their details are in req.currentUser
but req
isn't accessible from the layout.
I know I can do the following for each of the render
calls in my routes:
res.render('help', {
locals: { currentUser: req.currentUser }
});
But it seems there must be a better way than adding { currentUser: req.currentUser }
into the locals
every single one of my routes.
I'm still a Node newbie, so apologies if this is a stupid question.