Adding new function to jinja template using custom_components

I have two files in custom_components/my_template_functions

mainfest.json

{
    "domain": "my_template_functions",
    "name": "My Template Functions",
    "version": "1.0",
    "dependencies": [],
    "codeowners": [],
    "requirements": []
}

__init__.py

from homeassistant.helpers.template import TemplateEnvironment

def reverse_string(value):
    """Odwraca ciąg znaków."""
    return value[::-1]

async def async_setup(hass, config):
    """Zarejestruj funkcję w szablonach."""
    def setup_template_environment(env: TemplateEnvironment):
        env.filters["myreverse"] = reverse_string

    hass.helpers.template.register_template_environment(setup_template_environment)
    return True

When I try to use myreverse as filter in template like this

{{ "example string" | myreverse }}

I get error TemplateAssertionError: No filter named 'myreverse'

It seems I’m doing something wrong with registration. But I can’t find any information how to correct it.