fix: template_filter function
This commit is contained in:
parent
85c5d93cbd
commit
b6618c687d
1 changed files with 5 additions and 3 deletions
|
|
@ -662,7 +662,7 @@ class App(Scaffold):
|
||||||
|
|
||||||
@setupmethod
|
@setupmethod
|
||||||
def template_filter(
|
def template_filter(
|
||||||
self, name: str | None = None
|
self, f: T_template_filter | None = None, name: str | None = None
|
||||||
) -> t.Callable[[T_template_filter], T_template_filter]:
|
) -> t.Callable[[T_template_filter], T_template_filter]:
|
||||||
"""A decorator that is used to register custom template filter.
|
"""A decorator that is used to register custom template filter.
|
||||||
You can specify a name for the filter, otherwise the function
|
You can specify a name for the filter, otherwise the function
|
||||||
|
|
@ -679,8 +679,10 @@ class App(Scaffold):
|
||||||
def decorator(f: T_template_filter) -> T_template_filter:
|
def decorator(f: T_template_filter) -> T_template_filter:
|
||||||
self.add_template_filter(f, name=name)
|
self.add_template_filter(f, name=name)
|
||||||
return f
|
return f
|
||||||
|
|
||||||
return decorator
|
if not f:
|
||||||
|
return decorator
|
||||||
|
return decorator(f)
|
||||||
|
|
||||||
@setupmethod
|
@setupmethod
|
||||||
def add_template_filter(
|
def add_template_filter(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue