Created a twig extension as a service and successfully implement it