From 17e7fb450952010fde3777298bcb9c69e86ace7c Mon Sep 17 00:00:00 2001 From: Skami18 Date: Fri, 22 Jul 2011 18:45:41 +0200 Subject: [PATCH] =?UTF-8?q?Some=20changes=20in=20the=20templates=20loading?= =?UTF-8?q?=20system=20=E2=80=94=20documentation=20will=20be=20updated=20s?= =?UTF-8?q?oon?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - The `simple` theme can now be extended with the syntax `{% extends "!simple/index.html" %}` instead of `{% extends "simple/index.html" %}` to avoid conflicts with a `simple/` folder. - If a template is missing in a theme, it will be replaced by the corresponding template of the `simple` theme, so it's possible to make a new theme with only two file: a `base.html` file that extends the `base.html` file of the `simple` theme, and a CSS stylesheet, for example. --- pelican/generators.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pelican/generators.py b/pelican/generators.py index 5b51320d..d91283f3 100644 --- a/pelican/generators.py +++ b/pelican/generators.py @@ -31,13 +31,16 @@ class Generator(object): # templates cache self._templates = {} self._templates_path = os.path.expanduser(os.path.join(self.theme, 'templates')) + simple_loader = FileSystemLoader(os.path.join(os.path.dirname(os.path.abspath(__file__)), "themes", "simple", "templates")) self._env = Environment( loader=ChoiceLoader([ FileSystemLoader(self._templates_path), - PrefixLoader({'simple' : FileSystemLoader(os.path.join(os.path.dirname(os.path.abspath(__file__)), "themes", "simple", "templates"))}) + simple_loader, # implicit inheritance + PrefixLoader({'!simple' : simple_loader}) # explicit inheritance ]), extensions=self.settings.get('JINJA_EXTENSIONS', []), ) + debug('self._env.list_templates(): {0}'.format(self._env.list_templates())) # get custom Jinja filters from user settings custom_filters = self.settings.get('JINJA_FILTERS', {}) @@ -52,7 +55,6 @@ class Generator(object): try: self._templates[name] = self._env.get_template(name + '.html') except TemplateNotFound: - debug('self._env.list_templates(): {0}'.format(self._env.list_templates())) raise Exception('[templates] unable to load %s.html from %s' % ( name, self._templates_path)) return self._templates[name]