summaryrefslogtreecommitdiff
path: root/app/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/utils.py')
-rw-r--r--app/utils.py14
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 = {}