mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-21 04:10:17 +08:00
Merge pull request #8196 from quantopian/jinja-vars-from-config
DEV: Allow supplying jinja vars from python config.
This commit is contained in:
commit
3ee98d7557
@ -119,6 +119,11 @@ class IPythonHandler(AuthenticatedHandler):
|
||||
return Application.instance().log
|
||||
else:
|
||||
return app_log
|
||||
|
||||
@property
|
||||
def jinja_template_vars(self):
|
||||
"""User-supplied values to supply to jinja templates."""
|
||||
return self.settings.get('jinja_template_vars', {})
|
||||
|
||||
#---------------------------------------------------------------
|
||||
# URLs
|
||||
@ -250,6 +255,7 @@ class IPythonHandler(AuthenticatedHandler):
|
||||
sys_info=sys_info,
|
||||
contents_js_source=self.contents_js_source,
|
||||
version_hash=self.version_hash,
|
||||
**self.jinja_template_vars
|
||||
)
|
||||
|
||||
def get_json_body(self):
|
||||
|
@ -195,6 +195,7 @@ class NotebookWebApplication(web.Application):
|
||||
config_manager=config_manager,
|
||||
|
||||
# IPython stuff
|
||||
jinja_template_vars=ipython_app.jinja_template_vars,
|
||||
nbextensions_path=ipython_app.nbextensions_path,
|
||||
websocket_url=ipython_app.websocket_url,
|
||||
mathjax_url=ipython_app.mathjax_url,
|
||||
@ -520,6 +521,11 @@ class NotebookApp(BaseIPythonApplication):
|
||||
|
||||
jinja_environment_options = Dict(config=True,
|
||||
help="Supply extra arguments that will be passed to Jinja environment.")
|
||||
|
||||
jinja_template_vars = Dict(
|
||||
config=True,
|
||||
help="Extra variables to supply to jinja templates when rendering.",
|
||||
)
|
||||
|
||||
enable_mathjax = Bool(True, config=True,
|
||||
help="""Whether to enable MathJax for typesetting math/TeX
|
||||
|
@ -25,6 +25,7 @@ window.mathjax_url = "{{mathjax_url}}";
|
||||
|
||||
{% block params %}
|
||||
|
||||
{{super()}}
|
||||
data-project="{{project}}"
|
||||
data-base-url="{{base_url}}"
|
||||
data-ws-url="{{ws_url}}"
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
|
||||
{% block params %}
|
||||
|
||||
{{super()}}
|
||||
data-base-url="{{base_url}}"
|
||||
data-notebook-path="{{notebook_path}}"
|
||||
data-terminals-available="{{terminals_available}}"
|
||||
|
Loading…
Reference in New Issue
Block a user