From c462237b9d2f937cec96745b98728f85cbf92b37 Mon Sep 17 00:00:00 2001 From: Rachid Belaid Date: Mon, 3 Sep 2012 00:57:23 +0100 Subject: [PATCH] Add new setting EXTRA_TEMPLATES_PATHS This setting allow to use template which are not in the theme. Should help to build more generic themes around the content. --- docs/settings.rst | 4 ++++ pelican/generators.py | 7 +++++-- pelican/settings.py | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/settings.rst b/docs/settings.rst index ad08f020..2f5027b9 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -100,6 +100,10 @@ Setting name (default value) What doe This only applies if your content does not otherwise specify a summary. Setting to None will cause the summary to be a copy of the original content. +`EXTRA_TEMPLATES_PATHS` (``[]``) A list of paths you want Jinja2 to look for the templates. + Can be used to separate templates from the theme. + Example: projects, resume, profile ... + This templates need to use ``DIRECT_TEMPLATES`` setting ===================================================================== ===================================================================== diff --git a/pelican/generators.py b/pelican/generators.py index ae9334da..de10a126 100644 --- a/pelican/generators.py +++ b/pelican/generators.py @@ -36,8 +36,11 @@ class Generator(object): # templates cache self._templates = {} - self._templates_path = os.path.expanduser( - os.path.join(self.theme, 'templates')) + self._templates_path = [] + self._templates_path.append(os.path.expanduser( + os.path.join(self.theme, 'templates'))) + self._templates_path += self.settings.get('EXTRA_TEMPLATES_PATHS', []) + theme_path = os.path.dirname(os.path.abspath(__file__)) diff --git a/pelican/settings.py b/pelican/settings.py index 92c68ddc..c1ebe9b6 100644 --- a/pelican/settings.py +++ b/pelican/settings.py @@ -58,6 +58,7 @@ _DEFAULT_CONFIG = {'PATH': '.', 'TAG_CLOUD_STEPS': 4, 'TAG_CLOUD_MAX_ITEMS': 100, 'DIRECT_TEMPLATES': ('index', 'tags', 'categories', 'archives'), + 'EXTRA_TEMPLATES_PATHS' : [], 'PAGINATED_DIRECT_TEMPLATES': ('index', ), 'PELICAN_CLASS': 'pelican.Pelican', 'DEFAULT_DATE_FORMAT': '%a %d %B %Y',