Register a template test, available in any template rendered by the application. Works like the :meth:`app_template_test` decorator. Equivalent to :meth:`.Flask.add_template_test`. .. versionadded:: 0.10 :param name: the optional name of the test, otherwise the
(
self, f: ft.TemplateTestCallable, name: str | None = None
)
| 495 | |
| 496 | @setupmethod |
| 497 | def add_app_template_test( |
| 498 | self, f: ft.TemplateTestCallable, name: str | None = None |
| 499 | ) -> None: |
| 500 | """Register a template test, available in any template rendered by the |
| 501 | application. Works like the :meth:`app_template_test` decorator. Equivalent to |
| 502 | :meth:`.Flask.add_template_test`. |
| 503 | |
| 504 | .. versionadded:: 0.10 |
| 505 | |
| 506 | :param name: the optional name of the test, otherwise the |
| 507 | function name will be used. |
| 508 | """ |
| 509 | |
| 510 | def register_template(state: BlueprintSetupState) -> None: |
| 511 | state.app.jinja_env.tests[name or f.__name__] = f |
| 512 | |
| 513 | self.record_once(register_template) |
| 514 | |
| 515 | @setupmethod |
| 516 | def app_template_global( |