1
0
Fork 0
forked from github/pelican

Template from the simple themes can now be extended from the other themes

Templates from the `simple` themes can be used in the other themes using
the `extends` keyword:

    {% extends "simple/index.html" %}

This does not affect the behavior of Pelican:, so there is no need to modify
the existing themes.
This commit is contained in:
Skami18 2011-07-19 12:31:18 +02:00
commit 81722f65b8
2 changed files with 6 additions and 3 deletions

1
TODO
View file

@ -1,5 +1,4 @@
* Add a way to support pictures (see how sphinx makes that)
* Find a way to extend the existing templates instead of rewriting all from scratch.
* Make the program support UTF8-encoded files as input (and later: any encoding?)
* Add status support (draft, published, hidden)
* Add a serve + automatic generation behaviour.

View file

@ -8,7 +8,7 @@ import os
import math
import random
from jinja2 import Environment, FileSystemLoader
from jinja2 import Environment, FileSystemLoader, PrefixLoader, ChoiceLoader
from jinja2.exceptions import TemplateNotFound
from pelican.utils import copy, get_relative_path, process_translations, open
@ -32,7 +32,10 @@ class Generator(object):
self._templates = {}
self._templates_path = os.path.expanduser(os.path.join(self.theme, 'templates'))
self._env = Environment(
loader=FileSystemLoader(self._templates_path),
loader=ChoiceLoader([
FileSystemLoader(self._templates_path),
PrefixLoader({'simple' : FileSystemLoader(os.path.join(os.path.dirname(os.path.abspath(__file__)), "themes", "simple", "templates"))})
]),
extensions=self.settings.get('JINJA_EXTENSIONS', []),
)
@ -49,6 +52,7 @@ 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]