Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alaczi/twig-country-extension
Simple twig extension to convert two letter country codes to localized country names
https://github.com/alaczi/twig-country-extension
symphony twig twig-extension
Last synced: 21 days ago
JSON representation
Simple twig extension to convert two letter country codes to localized country names
- Host: GitHub
- URL: https://github.com/alaczi/twig-country-extension
- Owner: alaczi
- Created: 2016-01-19T15:47:06.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-03-25T11:00:55.000Z (about 5 years ago)
- Last Synced: 2024-03-14T23:21:27.411Z (3 months ago)
- Topics: symphony, twig, twig-extension
- Language: PHP
- Size: 3.91 KB
- Stars: 5
- Watchers: 0
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Lists
- awesome-twig - Country - Twig country filter extension for twig (Twig / Extensions)
- awesome-twig - Country - Twig country filter extension for twig (Twig / Extensions)
README
# Usage
## Require as dependency
```bash
composer require alaczi/twig-country-extension
```## Register the extension
### PHP
```php
$filter = new \alaczi\Twig\Extension\CountryExtension();
$twig = new Twig_Environment($loader);
$twig->addFilter($filter);
```### Symfony 2
```yaml
services:
alaczi.twig.country_extension:
class: alaczi\Twig\Extension\CountryExtension
tags:
- { name: twig.extension }
```### Silex
```php
$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
```twig
{{ countryCode|country }}
```