diff --git a/IPython/nbconvert/exporters/html.py b/IPython/nbconvert/exporters/html.py
index 8cb8675..aca6b97 100644
--- a/IPython/nbconvert/exporters/html.py
+++ b/IPython/nbconvert/exporters/html.py
@@ -12,7 +12,7 @@
# Imports
#-----------------------------------------------------------------------------
-from IPython.utils.traitlets import Unicode, List
+import os
from IPython.nbconvert import preprocessors
from IPython.config import Config
@@ -31,17 +31,14 @@ class HTMLExporter(TemplateExporter):
filters, just change the 'template_file' config option.
"""
- file_extension = Unicode(
- 'html', config=True,
- help="Extension of the file that should be written to disk"
- )
+ def _file_extension_default(self):
+ return 'html'
- mime_type = Unicode('text/html', config=True,
- help="MIME type of the result file, for HTTP response headers."
- )
+ def _default_template_path_default(self):
+ return os.path.join("..", "templates", "html")
- default_template = Unicode('full', config=True, help="""Flavor of the data
- format to use. I.E. 'full' or 'basic'""")
+ def _template_file_default(self):
+ return 'full'
output_mimetype = 'text/html'
diff --git a/IPython/nbconvert/exporters/latex.py b/IPython/nbconvert/exporters/latex.py
index 0a94b9d..46d8e01 100644
--- a/IPython/nbconvert/exporters/latex.py
+++ b/IPython/nbconvert/exporters/latex.py
@@ -16,7 +16,7 @@
import os
# IPython imports
-from IPython.utils.traitlets import Unicode, List
+from IPython.utils.traitlets import Unicode
from IPython.config import Config
from IPython.nbconvert import filters, preprocessors
@@ -35,22 +35,19 @@ class LatexExporter(TemplateExporter):
'template_file' config option. Place your template in the special "/latex"
subfolder of the "../templates" folder.
"""
-
- file_extension = Unicode(
- 'tex', config=True,
- help="Extension of the file that should be written to disk")
- default_template = Unicode('article', config=True, help="""Template of the
- data format to use. I.E. 'article' or 'report'""")
+ def _file_extension_default(self):
+ return 'tex'
+
+ def _template_file_default(self):
+ return 'article'
#Latex constants
- default_template_path = Unicode(
- os.path.join("..", "templates", "latex"), config=True,
- help="Path where the template files are located.")
+ def _default_template_path_default(self):
+ return os.path.join("..", "templates", "latex")
- template_skeleton_path = Unicode(
- os.path.join("..", "templates", "latex", "skeleton"), config=True,
- help="Path where the template skeleton files are located.")
+ def _template_skeleton_path_default(self):
+ return os.path.join("..", "templates", "latex", "skeleton")
#Special Jinja2 syntax that will not conflict when exporting latex.
jinja_comment_block_start = Unicode("((=", config=True)
diff --git a/IPython/nbconvert/exporters/markdown.py b/IPython/nbconvert/exporters/markdown.py
index 6a888ae..28708ae 100644
--- a/IPython/nbconvert/exporters/markdown.py
+++ b/IPython/nbconvert/exporters/markdown.py
@@ -13,7 +13,6 @@
#-----------------------------------------------------------------------------
from IPython.config import Config
-from IPython.utils.traitlets import Unicode
from .templateexporter import TemplateExporter
@@ -26,9 +25,11 @@ class MarkdownExporter(TemplateExporter):
Exports to a markdown document (.md)
"""
- file_extension = Unicode(
- 'md', config=True,
- help="Extension of the file that should be written to disk")
+ def _file_extension_default(self):
+ return 'md'
+
+ def _template_file_default(self):
+ return 'markdown'
output_mimetype = 'text/markdown'
diff --git a/IPython/nbconvert/exporters/python.py b/IPython/nbconvert/exporters/python.py
index b5a4293..5c7dbf4 100644
--- a/IPython/nbconvert/exporters/python.py
+++ b/IPython/nbconvert/exporters/python.py
@@ -12,8 +12,6 @@
# Imports
#-----------------------------------------------------------------------------
-from IPython.utils.traitlets import Unicode
-
from .templateexporter import TemplateExporter
#-----------------------------------------------------------------------------
@@ -24,9 +22,10 @@ class PythonExporter(TemplateExporter):
"""
Exports a Python code file.
"""
-
- file_extension = Unicode(
- 'py', config=True,
- help="Extension of the file that should be written to disk")
+ def _file_extension_default(self):
+ return 'py'
+
+ def _template_file_default(self):
+ return 'python'
output_mimetype = 'text/x-python'
diff --git a/IPython/nbconvert/exporters/rst.py b/IPython/nbconvert/exporters/rst.py
index e401c99..eaae267 100644
--- a/IPython/nbconvert/exporters/rst.py
+++ b/IPython/nbconvert/exporters/rst.py
@@ -12,7 +12,6 @@
# Imports
#-----------------------------------------------------------------------------
-from IPython.utils.traitlets import Unicode
from IPython.config import Config
from .templateexporter import TemplateExporter
@@ -26,9 +25,11 @@ class RSTExporter(TemplateExporter):
Exports restructured text documents.
"""
- file_extension = Unicode(
- 'rst', config=True,
- help="Extension of the file that should be written to disk")
+ def _file_extension_default(self):
+ return 'rst'
+
+ def _template_file_default(self):
+ return 'rst'
output_mimetype = 'text/restructuredtext'
diff --git a/IPython/nbconvert/exporters/slides.py b/IPython/nbconvert/exporters/slides.py
index 1a4ebec..8f4545e 100644
--- a/IPython/nbconvert/exporters/slides.py
+++ b/IPython/nbconvert/exporters/slides.py
@@ -12,8 +12,6 @@
# Imports
#-----------------------------------------------------------------------------
-from IPython.utils.traitlets import Unicode
-
from IPython.nbconvert import preprocessors
from IPython.config import Config
@@ -26,15 +24,13 @@ from .html import HTMLExporter
class SlidesExporter(HTMLExporter):
"""Exports HTML slides with reveal.js"""
- file_extension = Unicode(
- 'slides.html', config=True,
- help="Extension of the file that should be written to disk"
- )
+ def _file_extension_default(self):
+ return 'slides.html'
- output_mimetype = 'text/html'
+ def _template_file_default(self):
+ return 'slides_reveal'
- default_template = Unicode('reveal', config=True, help="""Template of the
- data format to use. I.E. 'reveal'""")
+ output_mimetype = 'text/html'
@property
def default_config(self):
diff --git a/IPython/nbconvert/exporters/templateexporter.py b/IPython/nbconvert/exporters/templateexporter.py
index e127ab9..f68bfea 100644
--- a/IPython/nbconvert/exporters/templateexporter.py
+++ b/IPython/nbconvert/exporters/templateexporter.py
@@ -173,15 +173,12 @@ class TemplateExporter(Exporter):
# template by name with extension added, then try loading the template
# as if the name is explicitly specified, then try the name as a
# 'flavor', and lastly just try to load the template by module name.
- module_name = self.__module__.rsplit('.', 1)[-1]
try_names = []
if self.template_file:
try_names.extend([
self.template_file + self.template_extension,
self.template_file,
- module_name + '_' + self.template_file + self.template_extension,
])
- try_names.append(module_name + self.template_extension)
for try_name in try_names:
self.log.debug("Attempting to load template %s", try_name)
try:
diff --git a/IPython/nbconvert/exporters/tests/test_slides.py b/IPython/nbconvert/exporters/tests/test_slides.py
index 7c7d008..86197b6 100644
--- a/IPython/nbconvert/exporters/tests/test_slides.py
+++ b/IPython/nbconvert/exporters/tests/test_slides.py
@@ -47,5 +47,5 @@ class TestSlidesExporter(ExportersTestsBase):
"""
Can a SlidesExporter export using the 'reveal' template?
"""
- (output, resources) = SlidesExporter(template_file='reveal').from_filename(self._get_notebook())
+ (output, resources) = SlidesExporter(template_file='slides_reveal').from_filename(self._get_notebook())
assert len(output) > 0
diff --git a/IPython/nbconvert/templates/html_basic.tpl b/IPython/nbconvert/templates/html/basic.tpl
similarity index 100%
rename from IPython/nbconvert/templates/html_basic.tpl
rename to IPython/nbconvert/templates/html/basic.tpl
diff --git a/IPython/nbconvert/templates/html_full.tpl b/IPython/nbconvert/templates/html/full.tpl
similarity index 98%
rename from IPython/nbconvert/templates/html_full.tpl
rename to IPython/nbconvert/templates/html/full.tpl
index cfc4516..21ab93c 100644
--- a/IPython/nbconvert/templates/html_full.tpl
+++ b/IPython/nbconvert/templates/html/full.tpl
@@ -1,4 +1,4 @@
-{%- extends 'html_basic.tpl' -%}
+{%- extends 'basic.tpl' -%}
{%- block header -%}
@@ -67,4 +67,4 @@ init_mathjax();
{% block footer %}