Merge pull request #8196 from quantopian/jinja-vars-from-config

DEV: Allow supplying jinja vars from python config.
This commit is contained in:
Min RK 2015-04-06 15:09:24 -07:00
commit 3ee98d7557
4 changed files with 14 additions and 1 deletions

View File

@ -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):

View File

@ -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

View File

@ -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}}"

View File

@ -4,7 +4,7 @@
{% block params %}
{{super()}}
data-base-url="{{base_url}}"
data-notebook-path="{{notebook_path}}"
data-terminals-available="{{terminals_available}}"