i had to define a new function that the one from the core extension calls sine the twig_escape_filter funciton takes the twig environment as an argument. something not available when not using templating.