from spaceapi_server.template import env_init def template_function(fn): """ Register the decorated function as a callable template function. :type fn: The function to register. """ # Make sure the Jinja2 environment is initialized env = env_init() # Add the function to the environment's globals env.globals[fn.__name__] = fn return fn def template_filter(fn): """ Register the decorated function as a template filter. :type fn: The function to register. """ # Make sure the Jinja2 environment is initialized env = env_init() # Add the function to the environment's filters env.filters[fn.__name__] = fn return fn def template_test(fn): """ Register the decorated function as a template test. :type fn: The function to register. """ # Make sure the Jinja2 environment is initialized env = env_init() # Add the function to the environment's tests env.tests[fn.__name__] = fn return fn