comparison env/lib/python3.9/site-packages/planemo/templates.py @ 0:4f3585e2f14b draft default tip

"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author shellac
date Mon, 22 Mar 2021 18:12:50 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4f3585e2f14b
1 """Templating abstraction around jinja2 for Planemo."""
2 try:
3 from jinja2 import Template
4 except ImportError:
5 Template = None # type: ignore
6
7 NO_JINJA2_MESSAGE = ("This functionality requires Jinja2 but this library is "
8 "unavailable. Install with `pip install jinja2`.")
9
10
11 def render(template_str: str, **kwds):
12 """Use jinja2 to render specified template."""
13 if Template is None:
14 raise Exception(NO_JINJA2_MESSAGE)
15 template = Template(template_str)
16 contents = template.render(**kwds)
17 return contents