code: def template_filter(self, name: Optional[str]=None) -> Callable:
          
          def decorator(func: Callable) -> Callable:
              self.add_template_filter(func, name=name)
              return func
          return decorator
docs: Add a template filter.
  
          This is designed to be used as a decorator. An example usage,
  
          .. code-block:: python
  
              @app.template_filter('name')
              def to_upper(value):
                  return value.upper()
  
          Arguments:
              name: The filter name (defaults to function name).