Show More
@@ -141,16 +141,20 b' class Exporter(Configurable):' | |||||
141 | self.environment.filters[key] = user_filter |
|
141 | self.environment.filters[key] = user_filter | |
142 |
|
142 | |||
143 |
|
143 | |||
144 | def from_notebook_node(self, nb): |
|
144 | def from_notebook_node(self, nb, resources=None): | |
145 | """ |
|
145 | """ | |
146 | Convert a notebook from a notebook node instance. |
|
146 | Convert a notebook from a notebook node instance. | |
147 |
|
147 | |||
148 | Parameters |
|
148 | Parameters | |
149 | ---------- |
|
149 | ---------- | |
150 | nb : Notebook node |
|
150 | nb : Notebook node | |
|
151 | resources : a dict of additional resources that | |||
|
152 | can be accessed read/write by transformers | |||
|
153 | and filters. | |||
151 | """ |
|
154 | """ | |
152 |
|
155 | if resources is None: | ||
153 |
|
|
156 | resources = {} | |
|
157 | nb, resources = self._preprocess(nb, resources) | |||
154 |
|
158 | |||
155 | #Load the template file. |
|
159 | #Load the template file. | |
156 | self.template = self.environment.get_template(self.template_file+self.template_extension) |
|
160 | self.template = self.environment.get_template(self.template_file+self.template_extension) | |
@@ -296,7 +300,7 b' class Exporter(Configurable):' | |||||
296 | self.environment.comment_end_string = self.jinja_comment_block_end |
|
300 | self.environment.comment_end_string = self.jinja_comment_block_end | |
297 |
|
301 | |||
298 |
|
302 | |||
299 | def _preprocess(self, nb): |
|
303 | def _preprocess(self, nb, resources): | |
300 | """ |
|
304 | """ | |
301 | Preprocess the notebook before passing it into the Jinja engine. |
|
305 | Preprocess the notebook before passing it into the Jinja engine. | |
302 | To preprocess the notebook is to apply all of the |
|
306 | To preprocess the notebook is to apply all of the | |
@@ -305,10 +309,11 b' class Exporter(Configurable):' | |||||
305 | ---------- |
|
309 | ---------- | |
306 | nb : notebook node |
|
310 | nb : notebook node | |
307 | notebook that is being exported. |
|
311 | notebook that is being exported. | |
|
312 | resources : a dict of additional resources that | |||
|
313 | can be accessed read/write by transformers | |||
|
314 | and filters. | |||
308 | """ |
|
315 | """ | |
309 |
|
316 | |||
310 | #Dict of 'resources' that can be filled by the transformers. |
|
|||
311 | resources = {} |
|
|||
312 |
|
317 | |||
313 | #Run each transformer on the notebook. Carry the output along |
|
318 | #Run each transformer on the notebook. Carry the output along | |
314 | #to each transformer |
|
319 | #to each transformer |
General Comments 0
You need to be logged in to leave comments.
Login now