Permalink
Browse files

Added support for Jinja2 extensions.

You can use the 'jinja2_extensions' configuration option to add
extensions to the Jinja2 template system.
  • Loading branch information...
1 parent 2f6dc79 commit 85ce004d1cf16e3d49b13d5bf014a33bd39dc4f3 @remram44 remram44 committed Sep 20, 2012
Showing with 9 additions and 4 deletions.
  1. +9 −4 wok/page.py
View
@@ -24,6 +24,13 @@ class Page(object):
tmpl_env = None
+ @staticmethod
+ def create_tmpl_env(options):
+ Page.tmpl_env = jinja2.Environment(
+ loader=GlobFileLoader(
+ options.get('template_dir', 'templates')),
+ extensions=options.get('jinja2_extensions', []))
+
def __init__(self, options, engine):
self.options = options
self.filename = None
@@ -50,8 +57,7 @@ def from_meta(cls, meta, options, engine, renderer=renderers.Plain):
# Make a template environment. Hopefully no one expects this to ever
# change after it is instantiated.
if Page.tmpl_env is None:
- Page.tmpl_env = jinja2.Environment(loader=GlobFileLoader(
- page.options.get('template_dir', 'templates')))
+ cls.create_tmpl_env(page.options)
page.build_meta()
return page
@@ -72,8 +78,7 @@ def from_file(cls, path, options, engine, renderer=renderers.Plain):
logging.info('Loading {0}'.format(os.path.basename(path)))
if Page.tmpl_env is None:
- Page.tmpl_env = jinja2.Environment(loader=GlobFileLoader(
- page.options.get('template_dir', 'templates')))
+ cls.create_tmpl_env(page.options)
page.path = path
page.filename = os.path.basename(path)

0 comments on commit 85ce004

Please sign in to comment.