|
13 | 13 | from .version import __version__
|
14 | 14 |
|
15 | 15 |
|
| 16 | +jinja_env = jinja2.Environment(loader=jinja2.FileSystemLoader( |
| 17 | + os.path.join(os.path.dirname(__file__), 'templates') |
| 18 | + ), |
| 19 | +) |
| 20 | + |
16 | 21 | class SyncHandler(IPythonHandler):
|
17 | 22 | def __init__(self, *args, **kwargs):
|
18 | 23 | super().__init__(*args, **kwargs)
|
@@ -128,19 +133,6 @@ def pull():
|
128 | 133 |
|
129 | 134 |
|
130 | 135 | class UIHandler(IPythonHandler):
|
131 |
| - def initialize(self): |
132 |
| - super().initialize() |
133 |
| - # FIXME: Is this really the best way to use jinja2 here? |
134 |
| - # I can't seem to get the jinja2 env in the base handler to |
135 |
| - # actually load templates from arbitrary paths ugh. |
136 |
| - jinja2_env = self.settings['jinja2_env'] |
137 |
| - jinja2_env.loader = jinja2.ChoiceLoader([ |
138 |
| - jinja2_env.loader, |
139 |
| - jinja2.FileSystemLoader( |
140 |
| - os.path.join(os.path.dirname(__file__), 'templates') |
141 |
| - ) |
142 |
| - ]) |
143 |
| - |
144 | 136 | @web.authenticated
|
145 | 137 | async def get(self):
|
146 | 138 | app_env = os.getenv('NBGITPULLER_APP', default='notebook')
|
@@ -169,10 +161,11 @@ async def get(self):
|
169 | 161 | path = 'tree/' + path
|
170 | 162 |
|
171 | 163 | self.write(
|
172 |
| - self.render_template( |
173 |
| - 'status.html', |
174 |
| - repo=repo, branch=branch, path=path, depth=depth, targetpath=targetpath, version=__version__ |
175 |
| - )) |
| 164 | + jinja_env.get_template('status.html').render( |
| 165 | + repo=repo, branch=branch, path=path, depth=depth, targetpath=targetpath, version=__version__, |
| 166 | + **self.template_namespace |
| 167 | + ) |
| 168 | + ) |
176 | 169 | await self.flush()
|
177 | 170 |
|
178 | 171 |
|
|
0 commit comments