alaczi/twig-country-extension

Twig country filter extension for twig

v1.2.0 2019-03-25 10:59 UTC

This package is auto-updated.

Last update: 2024-10-25 22:33:12 UTC


README

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