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
- Host: GitHub
- URL: https://github.com/parisek/twig-common
- Owner: parisek
- License: gpl-2.0
- Created: 2021-08-14T12:21:39.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-10-10T08:28:52.000Z (over 1 year ago)
- Last Synced: 2025-09-21T00:21:34.323Z (5 months ago)
- Topics: php, twig, twig-extension
- Language: PHP
- Homepage: https://packagist.org/packages/parisek/twig-common
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
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 %}
```