composer require alaczi/twig-country-extension
$filter = new \alaczi\Twig\Extension\CountryExtension();
$twig = new Twig_Environment($loader);
$twig->addFilter($filter);
services:
alaczi.twig.country_extension:
class: alaczi\Twig\Extension\CountryExtension
tags:
- { name: twig.extension }
$app['twig'] = $app->share($app->extend('twig', function ($twig, $app) {
/** @var \Twig_Environment $twig */
$twig->addExtension(new \alaczi\Twig\Extension\CountryExtension())
return $twig;
}));
{{ countryCode|country }}