mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-18 07:23:00 +00:00
Merge pull request #1872 from thedataincubator/template-vars
Allow extra variables to be passed into templates
This commit is contained in:
@@ -286,6 +286,10 @@ class JupyterHub(Application):
|
|||||||
def _template_paths_default(self):
|
def _template_paths_default(self):
|
||||||
return [os.path.join(self.data_files_path, 'templates')]
|
return [os.path.join(self.data_files_path, 'templates')]
|
||||||
|
|
||||||
|
template_vars = Dict(
|
||||||
|
help="Extra variables to be passed into jinja templates",
|
||||||
|
).tag(config=True)
|
||||||
|
|
||||||
confirm_no_ssl = Bool(False,
|
confirm_no_ssl = Bool(False,
|
||||||
help="""DEPRECATED: does nothing"""
|
help="""DEPRECATED: does nothing"""
|
||||||
).tag(config=True)
|
).tag(config=True)
|
||||||
@@ -1526,6 +1530,7 @@ class JupyterHub(Application):
|
|||||||
static_url_prefix=url_path_join(self.hub.base_url, 'static/'),
|
static_url_prefix=url_path_join(self.hub.base_url, 'static/'),
|
||||||
static_handler_class=CacheControlStaticFilesHandler,
|
static_handler_class=CacheControlStaticFilesHandler,
|
||||||
template_path=self.template_paths,
|
template_path=self.template_paths,
|
||||||
|
template_vars=self.template_vars,
|
||||||
jinja2_env=jinja_env,
|
jinja2_env=jinja_env,
|
||||||
version_hash=version_hash,
|
version_hash=version_hash,
|
||||||
subdomain_host=self.subdomain_host,
|
subdomain_host=self.subdomain_host,
|
||||||
|
@@ -752,7 +752,7 @@ class BaseHandler(RequestHandler):
|
|||||||
@property
|
@property
|
||||||
def template_namespace(self):
|
def template_namespace(self):
|
||||||
user = self.get_current_user()
|
user = self.get_current_user()
|
||||||
return dict(
|
ns = dict(
|
||||||
base_url=self.hub.base_url,
|
base_url=self.hub.base_url,
|
||||||
prefix=self.base_url,
|
prefix=self.base_url,
|
||||||
user=user,
|
user=user,
|
||||||
@@ -762,6 +762,9 @@ class BaseHandler(RequestHandler):
|
|||||||
static_url=self.static_url,
|
static_url=self.static_url,
|
||||||
version_hash=self.version_hash,
|
version_hash=self.version_hash,
|
||||||
)
|
)
|
||||||
|
if self.settings['template_vars']:
|
||||||
|
ns.update(self.settings['template_vars'])
|
||||||
|
return ns
|
||||||
|
|
||||||
def write_error(self, status_code, **kwargs):
|
def write_error(self, status_code, **kwargs):
|
||||||
"""render custom error pages"""
|
"""render custom error pages"""
|
||||||
|
Reference in New Issue
Block a user