user3659451
user3659451

Reputation: 2073

IPYTHON: adding a new folder to searchable template locations for `nbconvert`

The IPYTHON documentation implies there is a way to modify the config file to include an additional path for templates.

Please advise. I have a template file which I want to use, with extension *.tpl which I do not want to have to move around to the local directory of where I do my work.

Any tips? I've searched everywhere and can't find this. It seems to only search the local directory where I am running the ipython nbconvert test.ipynb --to slides --template output_toggle_html.

Thanks.

Upvotes: 0

Views: 329

Answers (1)

user3659451
user3659451

Reputation: 2073

In the ipython_nbconvert_config.py file located , you can enter the line c.TemplateExporter.template_path = ['.'] which will do the same as the default behavior, however you can add to this list. For example, the code below adds $IPYTHONDIR/nbextensions/templates and will search for *.tpl files in those locations, in the order in which they are provided in the list.

from os import environ
IPYTHONDIR = environ["IPYTHONDIR"]
template_rel_path = '/nbextensions/templates'
template_path = IPYTHONDIR + template_rel_path
c.TemplateExporter.template_path = [
                                '.',
                                template_path
                                    ]

Upvotes: 1

Related Questions