##// END OF EJS Templates
DEV: Support for configurable list of extra jinja template directories.
Scott Sanderson -
Show More
@@ -3,7 +3,9
3 3 import os
4 4 # Packagers: modify this line if you store the notebook static files elsewhere
5 5 DEFAULT_STATIC_FILES_PATH = os.path.join(os.path.dirname(__file__), "static")
6 # Packagers: modify this line if you store the notebook template files elsewhere
7 DEFAULT_TEMPLATE_FILES_PATH = os.path.join(os.path.dirname(__file__), "templates")
6 8
7 9 del os
8 10
9 from .nbextensions import install_nbextension No newline at end of file
11 from .nbextensions import install_nbextension
@@ -51,7 +51,10 from tornado import httpserver
51 51 from tornado import web
52 52 from tornado.log import LogFormatter, app_log, access_log, gen_log
53 53
54 from IPython.html import DEFAULT_STATIC_FILES_PATH
54 from IPython.html import (
55 DEFAULT_STATIC_FILES_PATH,
56 DEFAULT_TEMPLATE_FILES_PATH,
57 )
55 58 from .base.handlers import Template404
56 59 from .log import log_request
57 60 from .services.kernels.kernelmanager import MappingKernelManager
@@ -138,7 +141,10 class NotebookWebApplication(web.Application):
138 141 log, base_url, default_url, settings_overrides,
139 142 jinja_env_options=None):
140 143
141 _template_path = settings_overrides.get("template_path", os.path.join(os.path.dirname(__file__), "templates"))
144 _template_path = settings_overrides.get(
145 "template_path",
146 ipython_app.template_file_path,
147 )
142 148 if isinstance(_template_path, str):
143 149 _template_path = (_template_path,)
144 150 template_path = [os.path.expanduser(path) for path in _template_path]
@@ -519,7 +525,20 class NotebookApp(BaseIPythonApplication):
519 525 def static_file_path(self):
520 526 """return extra paths + the default location"""
521 527 return self.extra_static_paths + [DEFAULT_STATIC_FILES_PATH]
522
528
529 extra_template_paths = List(Unicode, config=True,
530 help="""Extra paths to search for serving jinja templates.
531
532 Can be used to override templates from IPython.html.templates."""
533 )
534 def _extra_template_paths_default(self):
535 return []
536
537 @property
538 def template_file_path(self):
539 """return extra paths + the default location"""
540 return self.extra_template_paths + [DEFAULT_TEMPLATE_FILES_PATH]
541
523 542 nbextensions_path = List(Unicode, config=True,
524 543 help="""paths for Javascript extensions. By default, this is just IPYTHONDIR/nbextensions"""
525 544 )
General Comments 0
You need to be logged in to leave comments. Login now