Twig extensions optimization

@umpirsky Duplicated?