def with_template(template=None, render_func=render_template):

    def decorator(f):
        @wraps(f)
        def wrapper(*args, **kwargs):
            template_name = template
            if template_name is None:
                template_name = request.endpoint.replace('.', '/') + '.html'
            ctx = f(*args, **kwargs)
            if ctx is None:
                ctx = {}
            elif not isinstance(ctx, dict):
                return ctx
            return render_func(template_name, **ctx)

        return wrapper

    return decorator
Render a template using the `dict` result of the function as context.
dataset/ETHPy150Open kofrasa/flask-apputils/flask_apputils/decorators.py/with_template