Skip to content

Latest commit

 

History

History
45 lines (32 loc) · 774 Bytes

readme.md

File metadata and controls

45 lines (32 loc) · 774 Bytes

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 }}