def templated(template=None):
def decorator(f):<EOL><INDENT>@wraps(f)<EOL>def decorated_function(*args, **kwargs):<EOL><INDENT>template_name = template<EOL>if template_name is None:<EOL><INDENT>template_name = request.endpoint.replace('<STR_LIT:.>', '<STR_LIT:/>') + '<STR_LIT>'<EOL><DEDENT>context = f(*args, **kwargs)<EOL>if context is None:<EOL><INDENT>context = {}<EOL><DEDENT>elif not isinstance(context, dict):<EOL><INDENT>return context<EOL><DEDENT>return render_template(template_name, **context)<EOL><DEDENT>return decorated_function<EOL><DEDENT>return decorator<EOL>
Template decorator.

    Ref: http://flask.pocoo.org/docs/patterns/viewdecorators/