Skip to content

Instantly share code, notes, and snippets.

@takluyver
Last active June 1, 2017 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takluyver/bfad315881a7f9be54ca4d18bd79d58c to your computer and use it in GitHub Desktop.
Save takluyver/bfad315881a7f9be54ca4d18bd79d58c to your computer and use it in GitHub Desktop.
Pass extra variables to nbconvert template
# Pass an extra variable to an nbconvert template
# Untested
from nbconvert.exporters import HTMLExporter
class MyExporter(HTMLExporter):
def from_notebook_node(self, nb, resources=None, my_var=None, **kw):
self.environment.globals['my_var'] = my_var
return super().from_notebook_node(nb, resources=resources, **kw)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment