Fix #103: Create Twig extension, move custom code there.