in scripts/generators/markdown_fields.py [0:0]
def templated(template_name):
"""Decorator function to simplify rendering a template.
:param template_name: the name of the template to be rendered
"""
def decorator(func):
@wraps(func)
def decorated_function(*args, **kwargs):
ctx = func(*args, **kwargs)
if ctx is None:
ctx = {}
elif not isinstance(ctx, dict):
return ctx
return render_template(template_name, **ctx)
return decorated_function
return decorator