jinja_partials
jinja_partials copied to clipboard
Automatically add request to context if it's present.
Passing request to render_partial seems like a frequent pattern, at least in my usecases where I generate links using url_for(). Maybe I'm doing something wrong :wink: It would be great if the request was passed automatically.
Thanks @dekoza How do you propose we pass the request automatically? Keep in mind that flask.request won't work because this library is used across frameworks (which have different ideas of what a request is).
I'm not against it if it can be done. But I didn't see how to accomplish this.
It could be done in https://github.com/mikeckennedy/jinja_partials/blob/31e813008dc60d1e8c0e7c2ad0fb6045ae54009a/jinja_partials/init.py#L58
It checks if flask is installed, and if yes, the render function could be replaced with one that automatically injects the context
Hey @mkrd that code only runs once at start up. How do you propose I get access to each individual request? I'm not against it, just not sure how to accomplish it.
Closing for inactivity and I'm not sure where to go with it. But feel free to jump in and revive it.