blob: 5096d17bcf88e0eb86a85d322fc0d8842f0a04b2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
from flask import Flask as _Flask
from flask import Blueprint as _Blueprint
if not hasattr(_Flask, 'template_test'):
# model `template_test` -- introduced with flask-0.10
class Flask(_Flask):
def template_test(self, name=None):
def decorator(f):
self.add_template_test(f, name=name)
return f
return decorator
def add_template_test(self, f, name=None):
self.jinja_env.tests[name or f.__name__] = f
class Blueprint(_Blueprint):
def app_template_test(self, name=None):
def decorator(f):
self.add_app_template_test(f, name=name)
return f
return decorator
def add_app_template_test(self, f, name=None):
def register_template(state):
state.app.jinja_env.tests[name or f.__name__] = f
self.record_once(register_template)
else:
Flask = _Flask
Blueprint = _Blueprint
del _Flask, _Blueprint
|