diff options
author | René 'Necoro' Neumann <necoro@necoro.net> | 2013-10-16 10:54:40 +0200 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.net> | 2013-10-16 10:54:40 +0200 |
commit | 9621f1d1dcde09617a2f9bf9908affece64ef643 (patch) | |
tree | 6f55aaeb27c12a44b13bb3d64184554155825c75 /app/utils.py | |
parent | 74e64cbef6af5f46ff1a2ca010a7ab60ba0c7fe0 (diff) | |
download | kosten-9621f1d1dcde09617a2f9bf9908affece64ef643.tar.gz kosten-9621f1d1dcde09617a2f9bf9908affece64ef643.tar.bz2 kosten-9621f1d1dcde09617a2f9bf9908affece64ef643.zip |
Allow @templated to be called raw, i.e. w/o ()
Diffstat (limited to '')
-rw-r--r-- | app/utils.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/app/utils.py b/app/utils.py index e6a7c95..1d5f73c 100644 --- a/app/utils.py +++ b/app/utils.py @@ -8,6 +8,12 @@ def _gen_tpl(endpoint): return endpoint.replace('.', '/') + '.jinja' def templated(template=None): + fun = None + if template is not None and callable(template): + # a function was passed in + fun = template + template = None + def decorator(f): @wraps(f) def decorated_function(*args, **kwargs): @@ -25,7 +31,11 @@ def templated(template=None): return ctx return render_template(template_name, **ctx) return decorated_function - return decorator + + if fun is None: + return decorator + else: + return decorator(fun) def redirect (target, **kwargs): code = kwargs.pop('_code', None) |