Skip to content

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

License

Notifications You must be signed in to change notification settings

parisek/twig-common

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Twig Common Extension

Installation

Twig Common Extension can be easily installed using composer

composer require parisek/twig-common

Usage

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

Filters

Will load YAML to variable

{% set sidebar = source('sidebar.yml')|yaml_parse %}

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

{{ "Hello"|t }}

Functions

Will generate unique ID on the page

{{ uniqueId() }}

Tokens

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

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