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

`request.render` does not pass the request to the context function #115

Closed
rubennorte opened this issue Apr 5, 2017 · 7 comments
Closed

`request.render` does not pass the request to the context function #115

rubennorte opened this issue Apr 5, 2017 · 7 comments
Milestone

Comments

@rubennorte
Copy link

@rubennorte rubennorte commented Apr 5, 2017

I that rendering a template with request.render is supposed to be equivalent to doing so with reply.view but the prior doesn't send request to the context function configured in server.views.

server.views({
  ...
  context: request => request.app.someProperty
});

Using reply.view works fine but with request.render request in undefined.

Edit: I needed this to use request.render as a workaround for #106

@rubennorte

This comment has been minimized.

Copy link
Author

@rubennorte rubennorte commented Apr 5, 2017

I just saw a test that specified that was the expected behaviour:

it('does not pass the request to the global context function (request)', (done) => {

Is there any reason for that? It seems counterintuitive that being a request method it doesn't use it.

@wswoodruff

This comment has been minimized.

Copy link
Contributor

@wswoodruff wswoodruff commented Nov 19, 2017

This is a great question, honestly I don't know why request.render doesn't pass the request to the global context. @hueniverse?

@hueniverse

This comment has been minimized.

Copy link
Member

@hueniverse hueniverse commented Nov 20, 2017

Been far too long for me to recall.

@devinivy

This comment has been minimized.

Copy link
Member

@devinivy devinivy commented Nov 20, 2017

Followed the blame and found this: #81. I can't see any particular reason, but @jagoda definitely is clear in the docs and tests about the behavior. It might just be for consistency between server.render() and request.render() versus h.view() and the view handler.

@wswoodruff

This comment has been minimized.

Copy link
Contributor

@wswoodruff wswoodruff commented Nov 20, 2017

Interesting, does anyone have thoughts on if these 3 should act the exact same? Assuming the server, request, and h all have the same realm when render()ing or calling view()?

@wswoodruff

This comment has been minimized.

Copy link
Contributor

@wswoodruff wswoodruff commented Nov 28, 2017

I'm currently focusing on a larger update in #135, and can get to this after I brush that up and it gets merged

@wswoodruff

This comment has been minimized.

Copy link
Contributor

@wswoodruff wswoodruff commented Dec 31, 2017

Yo @rubennorte I've got a PR for this here: #140

@wswoodruff wswoodruff closed this Jan 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.