aboutsummaryrefslogtreecommitdiffstats
path: root/nikola/plugins/template
diff options
context:
space:
mode:
authorLibravatarAgustin Henze <tin@sluc.org.ar>2014-03-09 03:14:40 +0100
committerLibravatarAgustin Henze <tin@sluc.org.ar>2014-03-09 03:14:40 +0100
commitfa50632a9d87c3989566fed3e49c160a132e0d14 (patch)
tree81f58cc0dcfbb34710856b59c034bc47c53d91dc /nikola/plugins/template
parent2828399ba5cbb14502b023d4de1ba02f13dd5055 (diff)
Imported Upstream version 6.4.0upstream/6.4.0
Diffstat (limited to 'nikola/plugins/template')
-rw-r--r--nikola/plugins/template/jinja.py5
-rw-r--r--nikola/plugins/template/mako.py8
2 files changed, 13 insertions, 0 deletions
diff --git a/nikola/plugins/template/jinja.py b/nikola/plugins/template/jinja.py
index 17c33d4..f14adfe 100644
--- a/nikola/plugins/template/jinja.py
+++ b/nikola/plugins/template/jinja.py
@@ -61,6 +61,11 @@ class JinjaTemplates(TemplateSystem):
self.lookup.loader = jinja2.FileSystemLoader(directories,
encoding='utf-8')
+ def set_site(self, site):
+ """Sets the site."""
+ self.site = site
+ self.lookup.filters.update(self.site.config['TEMPLATE_FILTERS'])
+
def render_template(self, template_name, output_name, context):
"""Render the template into output_name using context."""
if jinja2 is None:
diff --git a/nikola/plugins/template/mako.py b/nikola/plugins/template/mako.py
index 45f4335..5a23230 100644
--- a/nikola/plugins/template/mako.py
+++ b/nikola/plugins/template/mako.py
@@ -49,6 +49,7 @@ class MakoTemplates(TemplateSystem):
lookup = None
cache = {}
+ filters = {}
def get_deps(self, filename):
text = util.read_file(filename)
@@ -81,6 +82,11 @@ class MakoTemplates(TemplateSystem):
module_directory=cache_dir,
output_encoding='utf-8')
+ def set_site(self, site):
+ """Sets the site."""
+ self.site = site
+ self.filters.update(self.site.config['TEMPLATE_FILTERS'])
+
def render_template(self, template_name, output_name, context):
"""Render the template into output_name using context."""
context['striphtml'] = striphtml
@@ -95,6 +101,8 @@ class MakoTemplates(TemplateSystem):
def render_template_to_string(self, template, context):
""" Render template to a string using context. """
+ context = context.update(self.filters)
+
return Template(template).render(**context)
def template_deps(self, template_name):