Fixed templating circular reference and create a twig extension