jinja2_environment_from_request() plugin hook

Closes #2225
This commit is contained in:
Simon Willison 2024-01-05 14:33:23 -08:00 committed by GitHub
commit c7a4706bcc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 128 additions and 25 deletions

View file

@ -57,7 +57,8 @@ def handle_exception(datasette, request, exception):
if request.path.split("?")[0].endswith(".json"):
return Response.json(info, status=status, headers=headers)
else:
template = datasette.jinja_env.select_template(templates)
environment = datasette.get_jinja_environment(request)
template = environment.select_template(templates)
return Response.html(
await template.render_async(
dict(