'The @app.view(template) decorator defines a template to format the handler function.
The function returns a dict of keyword arguments for Template.render().'

def view(self, template, cached=True):

    def decorator(handler):
        def wrapper(*args, **kwargs):
            if (not hasattr(template, 'render')):
                t = Template(template, root=self.static, cached=cached)
            else:
                t = template
            v = handler(*args, **kwargs)
            if isinstance(v, dict):
                return t.render(**v)
            return t.render(*v)
        return wrapper
    return decorator
