diff --git a/jupyterhub/app.py b/jupyterhub/app.py index 65059520..49191ed8 100644 --- a/jupyterhub/app.py +++ b/jupyterhub/app.py @@ -286,6 +286,10 @@ class JupyterHub(Application): def _template_paths_default(self): 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, help="""DEPRECATED: does nothing""" ).tag(config=True) @@ -1526,6 +1530,7 @@ class JupyterHub(Application): static_url_prefix=url_path_join(self.hub.base_url, 'static/'), static_handler_class=CacheControlStaticFilesHandler, template_path=self.template_paths, + template_vars=self.template_vars, jinja2_env=jinja_env, version_hash=version_hash, subdomain_host=self.subdomain_host, diff --git a/jupyterhub/handlers/base.py b/jupyterhub/handlers/base.py index dd434dcb..e4637b15 100644 --- a/jupyterhub/handlers/base.py +++ b/jupyterhub/handlers/base.py @@ -752,7 +752,7 @@ class BaseHandler(RequestHandler): @property def template_namespace(self): user = self.get_current_user() - return dict( + ns = dict( base_url=self.hub.base_url, prefix=self.base_url, user=user, @@ -762,6 +762,9 @@ class BaseHandler(RequestHandler): static_url=self.static_url, 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): """render custom error pages"""