##// END OF EJS Templates
Remove magic for loading templates from module names
Thomas Kluyver -
Show More
@@ -31,17 +31,11 b' class HTMLExporter(TemplateExporter):'
31 filters, just change the 'template_file' config option.
31 filters, just change the 'template_file' config option.
32 """
32 """
33
33
34 file_extension = Unicode(
34 def _file_extension_default(self):
35 'html', config=True,
35 return 'html'
36 help="Extension of the file that should be written to disk"
37 )
38
36
39 mime_type = Unicode('text/html', config=True,
37 def _template_file_default(self):
40 help="MIME type of the result file, for HTTP response headers."
38 return 'html_full'
41 )
42
43 default_template = Unicode('full', config=True, help="""Flavor of the data
44 format to use. I.E. 'full' or 'basic'""")
45
39
46 output_mimetype = 'text/html'
40 output_mimetype = 'text/html'
47
41
@@ -35,14 +35,17 b' class LatexExporter(TemplateExporter):'
35 'template_file' config option. Place your template in the special "/latex"
35 'template_file' config option. Place your template in the special "/latex"
36 subfolder of the "../templates" folder.
36 subfolder of the "../templates" folder.
37 """
37 """
38
39 def _file_extension_default(self):
40 return 'tex'
41
42 def _template_file_default(self):
43 return 'article'
38
44
39 file_extension = Unicode(
45 file_extension = Unicode(
40 'tex', config=True,
46 'tex', config=True,
41 help="Extension of the file that should be written to disk")
47 help="Extension of the file that should be written to disk")
42
48
43 default_template = Unicode('article', config=True, help="""Template of the
44 data format to use. I.E. 'article' or 'report'""")
45
46 #Latex constants
49 #Latex constants
47 default_template_path = Unicode(
50 default_template_path = Unicode(
48 os.path.join("..", "templates", "latex"), config=True,
51 os.path.join("..", "templates", "latex"), config=True,
@@ -26,9 +26,11 b' class MarkdownExporter(TemplateExporter):'
26 Exports to a markdown document (.md)
26 Exports to a markdown document (.md)
27 """
27 """
28
28
29 file_extension = Unicode(
29 def _file_extension_default(self):
30 'md', config=True,
30 return 'md'
31 help="Extension of the file that should be written to disk")
31
32 def _template_file_default(self):
33 return 'markdown'
32
34
33 output_mimetype = 'text/markdown'
35 output_mimetype = 'text/markdown'
34
36
@@ -24,9 +24,10 b' class PythonExporter(TemplateExporter):'
24 """
24 """
25 Exports a Python code file.
25 Exports a Python code file.
26 """
26 """
27
27 def _file_extension_default(self):
28 file_extension = Unicode(
28 return 'py'
29 'py', config=True,
29
30 help="Extension of the file that should be written to disk")
30 def _template_file_default(self):
31 return 'python'
31
32
32 output_mimetype = 'text/x-python'
33 output_mimetype = 'text/x-python'
@@ -26,9 +26,11 b' class RSTExporter(TemplateExporter):'
26 Exports restructured text documents.
26 Exports restructured text documents.
27 """
27 """
28
28
29 file_extension = Unicode(
29 def _file_extension_default(self):
30 'rst', config=True,
30 return 'rst'
31 help="Extension of the file that should be written to disk")
31
32 def _template_file_default(self):
33 return 'rst'
32
34
33 output_mimetype = 'text/restructuredtext'
35 output_mimetype = 'text/restructuredtext'
34
36
@@ -26,15 +26,13 b' from .html import HTMLExporter'
26 class SlidesExporter(HTMLExporter):
26 class SlidesExporter(HTMLExporter):
27 """Exports HTML slides with reveal.js"""
27 """Exports HTML slides with reveal.js"""
28
28
29 file_extension = Unicode(
29 def _file_extension_default(self):
30 'slides.html', config=True,
30 return 'slides.html'
31 help="Extension of the file that should be written to disk"
32 )
33
31
34 output_mimetype = 'text/html'
32 def _template_file_default(self):
33 return 'slides_reveal'
35
34
36 default_template = Unicode('reveal', config=True, help="""Template of the
35 output_mimetype = 'text/html'
37 data format to use. I.E. 'reveal'""")
38
36
39 @property
37 @property
40 def default_config(self):
38 def default_config(self):
@@ -173,15 +173,12 b' class TemplateExporter(Exporter):'
173 # template by name with extension added, then try loading the template
173 # template by name with extension added, then try loading the template
174 # as if the name is explicitly specified, then try the name as a
174 # as if the name is explicitly specified, then try the name as a
175 # 'flavor', and lastly just try to load the template by module name.
175 # 'flavor', and lastly just try to load the template by module name.
176 module_name = self.__module__.rsplit('.', 1)[-1]
177 try_names = []
176 try_names = []
178 if self.template_file:
177 if self.template_file:
179 try_names.extend([
178 try_names.extend([
180 self.template_file + self.template_extension,
179 self.template_file + self.template_extension,
181 self.template_file,
180 self.template_file,
182 module_name + '_' + self.template_file + self.template_extension,
183 ])
181 ])
184 try_names.append(module_name + self.template_extension)
185 for try_name in try_names:
182 for try_name in try_names:
186 self.log.debug("Attempting to load template %s", try_name)
183 self.log.debug("Attempting to load template %s", try_name)
187 try:
184 try:
1 NO CONTENT: file renamed from IPython/nbconvert/templates/latex/latex_article.tplx to IPython/nbconvert/templates/latex/article.tplx
NO CONTENT: file renamed from IPython/nbconvert/templates/latex/latex_article.tplx to IPython/nbconvert/templates/latex/article.tplx
1 NO CONTENT: file renamed from IPython/nbconvert/templates/latex/latex_base.tplx to IPython/nbconvert/templates/latex/base.tplx
NO CONTENT: file renamed from IPython/nbconvert/templates/latex/latex_base.tplx to IPython/nbconvert/templates/latex/base.tplx
1 NO CONTENT: file renamed from IPython/nbconvert/templates/latex/latex_report.tplx to IPython/nbconvert/templates/latex/report.tplx
NO CONTENT: file renamed from IPython/nbconvert/templates/latex/latex_report.tplx to IPython/nbconvert/templates/latex/report.tplx
@@ -1,6 +1,6 b''
1 ((= Black&white ipython input/output style =))
1 ((= Black&white ipython input/output style =))
2
2
3 ((*- extends 'latex_base.tplx' -*))
3 ((*- extends 'base.tplx' -*))
4
4
5 %===============================================================================
5 %===============================================================================
6 % Input
6 % Input
@@ -1,6 +1,6 b''
1 ((= Black&white Python input/output style =))
1 ((= Black&white Python input/output style =))
2
2
3 ((*- extends 'latex_base.tplx' -*))
3 ((*- extends 'base.tplx' -*))
4
4
5 %===============================================================================
5 %===============================================================================
6 % Input
6 % Input
@@ -1,6 +1,6 b''
1 ((= IPython input/output style =))
1 ((= IPython input/output style =))
2
2
3 ((*- extends 'latex_base.tplx' -*))
3 ((*- extends 'base.tplx' -*))
4
4
5 % Custom definitions
5 % Custom definitions
6 ((* block definitions *))
6 ((* block definitions *))
@@ -1,6 +1,6 b''
1 ((= Python input/output style =))
1 ((= Python input/output style =))
2
2
3 ((*- extends 'latex_base.tplx' -*))
3 ((*- extends 'base.tplx' -*))
4
4
5 % Custom definitions
5 % Custom definitions
6 ((* block definitions *))
6 ((* block definitions *))
General Comments 0
You need to be logged in to leave comments. Login now