mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
add the request parameter to render_template
This allows us to inspect things about the request we're rendering from. * Use render_template(request, ...) in aurweb.routers.auth Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
5d4a5deddf
commit
4423326cec
4 changed files with 12 additions and 6 deletions
|
@ -39,7 +39,10 @@ def make_context(request: Request, title: str, next: str = None):
|
|||
}
|
||||
|
||||
|
||||
def render_template(path: str, context: dict, status_code=int(HTTPStatus.OK)):
|
||||
def render_template(request: Request,
|
||||
path: str,
|
||||
context: dict,
|
||||
status_code=int(HTTPStatus.OK)):
|
||||
""" Render a Jinja2 multi-lingual template with some context. """
|
||||
|
||||
# Create a deep copy of our jinja2 environment. The environment in
|
||||
|
@ -54,4 +57,7 @@ def render_template(path: str, context: dict, status_code=int(HTTPStatus.OK)):
|
|||
|
||||
template = templates.get_template(path)
|
||||
rendered = template.render(context)
|
||||
return HTMLResponse(rendered, status_code=status_code)
|
||||
|
||||
response = HTMLResponse(rendered, status_code=status_code)
|
||||
response.set_cookie("AURLANG", context.get("language"))
|
||||
return response
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue