Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I access express "req" inside template? #56

Closed
juanmaia opened this issue Jan 29, 2014 · 3 comments
Closed

How can I access express "req" inside template? #56

juanmaia opened this issue Jan 29, 2014 · 3 comments

Comments

@juanmaia
Copy link

I'm using ect with express.
Is it possible to access req.session inside a template?
<%- req.session.user %> or <%- @req.session.user %>

@igorkova
Copy link

I can't access ANY locals var inside template.

Ok, now I see: #34 so it's known issue apparently

@juanmaia
Copy link
Author

@igorkova you just need to prefix all locals inside a template with @.

@yuri-karadzhov
Copy link

It's express question. You can access it trough locals:

app.use(function(req, res, next) {
  res.locals.req = req;
  return  next();
});

But you probably do not need all req, so you can pass whatever you want. Look trough express issue if will have any troubles with session.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants