diff options
author | René 'Necoro' Neumann <necoro@necoro.net> | 2013-04-16 00:21:01 +0200 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.net> | 2013-04-16 00:21:01 +0200 |
commit | b9b9200795b9fe7f6d054f117934e179a44f0224 (patch) | |
tree | a01181e454b49f18fb9d04de471591953c281a9f /app/utils.py | |
parent | 02172e39c15272f9567bd39a28ec24d0270ea70f (diff) | |
download | kosten-b9b9200795b9fe7f6d054f117934e179a44f0224.tar.gz kosten-b9b9200795b9fe7f6d054f117934e179a44f0224.tar.bz2 kosten-b9b9200795b9fe7f6d054f117934e179a44f0224.zip |
Fix templated
Diffstat (limited to '')
-rw-r--r-- | app/utils.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/app/utils.py b/app/utils.py index caacea7..67b4897 100644 --- a/app/utils.py +++ b/app/utils.py @@ -2,14 +2,20 @@ from functools import wraps from flask import request, render_template, url_for from flask import redirect as _redirect +def _gen_tpl(endpoint): + return endpoint.replace('.', '/') + '.jinja' + def templated(template=None): def decorator(f): @wraps(f) def decorated_function(*args, **kwargs): - template_name = template - if template_name is None: - template_name = request.endpoint \ - .replace('.', '/') + '.jinja' + if template is None: + template_name = _gen_tpl(request.endpoint) + elif template[0] == '.' and request.blueprint is not None: + template_name = _gen_tpl(request.blueprint + template) + else: + template_name = template + ctx = f(*args, **kwargs) if ctx is None: ctx = {} |