diff options
-rw-r--r-- | render.py | 4 | ||||
-rw-r--r-- | templates/host.html | 6 | ||||
-rw-r--r-- | utils.py | 10 |
3 files changed, 16 insertions, 4 deletions
@@ -4,8 +4,7 @@ import yaml import os import jinja2 import optparse -from utils import filters -from utils import tests +from utils import filters, tests, globals class Renderer: def __init__(self, output_dir): @@ -16,6 +15,7 @@ class Renderer: loader = jinja2.FileSystemLoader(template_dir)) self.env.filters.update(filters) self.env.tests.update(tests) + self.env.globals.update(globals) self.output_dir = output_dir self.templates = {} diff --git a/templates/host.html b/templates/host.html index 09c4f9d..bf30fd2 100644 --- a/templates/host.html +++ b/templates/host.html @@ -37,8 +37,10 @@ <dt>maintainers</dt> <dd> {% for maintainer in maintainers %} - <a href="mailto:{{maintainer}}@spline.de">{{maintainer}}</a>{% if not loop.last %}, {% endif %} - {% endfor %} + {% set name, mail = get_contact_info(maintainer) %} + <a href="mailto:{{mail}}">{{name}}</a> + {% if not loop.last %}, {% endif %} + {% endfor %} </dd> {% endif %} {% if groups is defined %} @@ -8,6 +8,12 @@ def get_os_name(name): def select_with_attribute(iterable, attribute, result=True): return [value for value in iterable if (attribute in value) == result] +def get_contact_info(maintainer): + if type(maintainer) is dict: + return maintainer.popitem() + else: + return (maintainer, "%s@spline.de" % (maintainer)) + def is_iterable(obj): if isinstance(obj, collections.Iterable): return True @@ -21,3 +27,7 @@ filters = [ tests = [ ('iterable', is_iterable) ] + +globals = [ + ('get_contact_info', get_contact_info) +] |