diff options
Diffstat (limited to 'render.py')
-rw-r--r-- | render.py | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -9,9 +9,13 @@ class Renderer: def __init__(self, output_dir): self.env = jinja2.Environment( loader = jinja2.FileSystemLoader('./templates')) + self.env.filters['select_with_attribute'] = self.select_with_attribute self.output_dir = output_dir self.templates = {} + def select_with_attribute(self, iterable, attribute, result=True): + return [value for value in iterable if (attribute in value) == result] + def _render(self, template, filename, **kwargs): if template not in self.templates: self.templates[template] = self.env.get_template(template) |