parisek/twig-common

A Twig extension with common functions and filters

Installs: 558

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/parisek/twig-common

v1.1.0 2024-10-10 08:27 UTC

This package is auto-updated.

Last update: 2025-10-10 10:33:09 UTC


README

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