Merge pull request #1872 from thedataincubator/template-vars

Allow extra variables to be passed into templates
This commit is contained in:
Min RK
2018-05-07 20:33:44 +02:00
committed by GitHub
2 changed files with 9 additions and 1 deletions

View File

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

View File

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