mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Merge pull request #2234 from dwarvenhoard/feature/extension-setting
Add setting so template extensions are configurable
This commit is contained in:
commit
598f9fbc83
3 changed files with 17 additions and 5 deletions
|
|
@ -699,6 +699,10 @@ Template pages
|
||||||
'src/resume.html': 'dest/resume.html',
|
'src/resume.html': 'dest/resume.html',
|
||||||
'src/contact.html': 'dest/contact.html'}
|
'src/contact.html': 'dest/contact.html'}
|
||||||
|
|
||||||
|
.. data:: TEMPLATE_EXTENSION = ['.html']
|
||||||
|
|
||||||
|
The extensions to use when looking up template files from template names.
|
||||||
|
|
||||||
.. data:: DIRECT_TEMPLATES = ['index', 'categories', 'authors', 'archives']
|
.. data:: DIRECT_TEMPLATES = ['index', 'categories', 'authors', 'archives']
|
||||||
|
|
||||||
List of templates that are used directly to render content. Typically direct
|
List of templates that are used directly to render content. Typically direct
|
||||||
|
|
|
||||||
|
|
@ -86,12 +86,19 @@ class Generator(object):
|
||||||
templates ready to use with Jinja2.
|
templates ready to use with Jinja2.
|
||||||
"""
|
"""
|
||||||
if name not in self._templates:
|
if name not in self._templates:
|
||||||
try:
|
for ext in self.settings['TEMPLATE_EXTENSIONS']:
|
||||||
self._templates[name] = self.env.get_template(name + '.html')
|
try:
|
||||||
except TemplateNotFound:
|
self._templates[name] = self.env.get_template(name + ext)
|
||||||
|
break
|
||||||
|
except TemplateNotFound:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if name not in self._templates:
|
||||||
raise PelicanTemplateNotFound(
|
raise PelicanTemplateNotFound(
|
||||||
'[templates] unable to load {}.html from {}'.format(
|
'[templates] unable to load {}[{}] from {}'.format(
|
||||||
name, self._templates_path))
|
name, ', '.join(self.settings['TEMPLATE_EXTENSIONS']),
|
||||||
|
self._templates_path))
|
||||||
|
|
||||||
return self._templates[name]
|
return self._templates[name]
|
||||||
|
|
||||||
def _include_path(self, path, extensions=None):
|
def _include_path(self, path, extensions=None):
|
||||||
|
|
|
||||||
|
|
@ -134,6 +134,7 @@ DEFAULT_CONFIG = {
|
||||||
'PLUGINS': [],
|
'PLUGINS': [],
|
||||||
'PYGMENTS_RST_OPTIONS': {},
|
'PYGMENTS_RST_OPTIONS': {},
|
||||||
'TEMPLATE_PAGES': {},
|
'TEMPLATE_PAGES': {},
|
||||||
|
'TEMPLATE_EXTENSIONS': ['.html'],
|
||||||
'IGNORE_FILES': ['.#*'],
|
'IGNORE_FILES': ['.#*'],
|
||||||
'SLUG_SUBSTITUTIONS': (),
|
'SLUG_SUBSTITUTIONS': (),
|
||||||
'INTRASITE_LINK_REGEX': '[{|](?P<what>.*?)[|}]',
|
'INTRASITE_LINK_REGEX': '[{|](?P<what>.*?)[|}]',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue