mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Expose extra_template_vars in _contex=1, refs #693
This commit is contained in:
parent
09253817de
commit
e89b0ef2f9
3 changed files with 14 additions and 11 deletions
|
|
@ -14,6 +14,7 @@ from pathlib import Path
|
|||
|
||||
import click
|
||||
from markupsafe import Markup
|
||||
import jinja2
|
||||
from jinja2 import ChoiceLoader, Environment, FileSystemLoader, PrefixLoader, escape
|
||||
from jinja2.environment import Template
|
||||
import uvicorn
|
||||
|
|
@ -612,6 +613,11 @@ class Datasette:
|
|||
},
|
||||
**extra_template_vars,
|
||||
}
|
||||
if request and request.args.get("_context") and self.config("template_debug"):
|
||||
return "<pre>{}</pre>".format(
|
||||
jinja2.escape(json.dumps(template_context, default=repr, indent=4))
|
||||
)
|
||||
|
||||
return await template.render_async(template_context)
|
||||
|
||||
def _asset_urls(self, key, template, context):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue