Fix error message for twig function
Refactorise twig extension and add require twig tag