An open API service indexing awesome lists of open source software.

https://github.com/parisek/twig-common

Twig Common Extension - some useful filters, functions, tokens to my twig template workflow
https://github.com/parisek/twig-common

php twig twig-extension

Last synced: 17 days ago
JSON representation

Twig Common Extension - some useful filters, functions, tokens to my twig template workflow

Awesome Lists containing this project

README

          

Twig Common Extension
=====================

## Installation

Twig Common Extension can be easily installed using [composer](http://getcomposer.org/)

composer require parisek/twig-common

## Usage

```php
$twig = new Twig_Environment($loader);
$twig->addExtension(new Parisek\Twig\CommonExtension());
```

## Filters

Will load YAML to variable
```twig
{% set sidebar = source('sidebar.yml')|yaml_parse %}
```

Will return content without translation (useful for debug without translation extension)
```twig
{{ "Hello"|t }}
```

## Functions

Will generate unique ID on the page
```twig
{{ uniqueId() }}
```

## Tokens
Will return content without translation (useful for debug without translation extension)

```twig
{% trans with {'context': 'domain name'} %}{{ variable }}{% endtrans %}
```