Download the PHP package felds/twig-extra without Composer
On this page you can find all versions of the php package felds/twig-extra. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download felds/twig-extra
More information about felds/twig-extra
Files in felds/twig-extra
Download felds/twig-extra
More information about felds/twig-extra
Files in felds/twig-extra
Vendor felds
Package twig-extra
Short Description Custom Twig tags and extensions (switch tag).
License MIT
Package twig-extra
Short Description Custom Twig tags and extensions (switch tag).
License MIT
Please rate this library. Is it a good library?
Informations about the package twig-extra
felds/twig-extra
Custom Twig extras for Twig 3.22+ and PHP 8.4+:
switchtag?.nullsafe operator
Installation
Usage
Register the desired extensions with Twig:
In Symfony, you can let autoconfigure pick it up by registering the services:
Switch tag ({% switch %})
Match a value against multiple comparisons, picking the first case that evaluates truthy:
- Supports all Twig comparison operators (==, !=, >, <, >=, <=,
is same as,in,not in,matches,starts with,ends with, etc.). - Cases are evaluated top-down; the first hit wins, otherwise
defaultruns when present. - The switch value is stored internally and the original context is restored after the block.
Nullsafe operator (?.)
Access attributes and call methods without throwing when the left side is null or missing:
- If the base value is null or undefined, the chain short-circuits to null.
- Works with arrays, objects, property fetches, and method calls.
- Respects strict variables (nullsafe short-circuits instead of raising).
Tests
License
MIT
Changelog
See CHANGELOG.md.
All versions of twig-extra with dependencies
PHP Build Version
Package Version
The package felds/twig-extra contains the following files
Loading the files please wait ...