Skip to content

Simple twig extension to convert two letter country codes to localized country names

Notifications You must be signed in to change notification settings

alaczi/twig-country-extension

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Usage

Require as dependency

    composer require alaczi/twig-country-extension

Register the extension

PHP

    $filter = new \alaczi\Twig\Extension\CountryExtension();
    $twig = new Twig_Environment($loader);
    $twig->addFilter($filter);

Symfony 2

services:
    alaczi.twig.country_extension:
        class: alaczi\Twig\Extension\CountryExtension
        tags:
            - { name: twig.extension }

Silex

    $app['twig'] = $app->share($app->extend('twig', function ($twig, $app) {
        /** @var \Twig_Environment $twig */
        $twig->addExtension(new \alaczi\Twig\Extension\CountryExtension())
        return $twig;
    }));

Usage in twig

    {{ countryCode|country }}

About

Simple twig extension to convert two letter country codes to localized country names

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages