view venv/lib/python2.7/site-packages/planemo/templates.py @ 0:d67268158946 draft

planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
author bcclaywell
date Mon, 12 Oct 2015 17:43:33 -0400
parents
children
line wrap: on
line source

try:
    from jinja2 import Template
except ImportError:
    Template = None

NO_JINJA2_MESSAGE = ("This functionality requires Jinja2 but this library is "
                     "unavailable. Install with `pip install jinja2`.")


def render(template_str, **kwds):
    """ Use jinja2 to render a template
    """
    if Template is None:
        raise Exception(NO_JINJA2_MESSAGE)
    template = Template(template_str)
    contents = template.render(**kwds)
    return contents