Skip to content

Instantly share code, notes, and snippets.

@popomore
Created September 27, 2012 04:19
Show Gist options
  • Save popomore/3792128 to your computer and use it in GitHub Desktop.
Save popomore/3792128 to your computer and use it in GitHub Desktop.
app.dynamicHelpers to res.locals

假如模板上要使用 session

before

app.dynamicHelpers({
    session: function (req, res) {
        return req.session;
    }
});

after

app.use(function(req, res, next) {
    res.locals.session = req.session;
    next();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment