zentlix/twig-extensions

Additional Twig extensions for Spiral Framework.

1.x-dev 2023-05-04 18:37 UTC

This package is auto-updated.

Last update: 2024-11-11 03:01:05 UTC


README

PHP Version Require Latest Stable Version phpunit psalm Codecov Total Downloads type-coverage psalm-level

Requirements

Make sure that your server is configured with following PHP version and extensions:

  • PHP 8.1+
  • Spiral framework 3.7+

Installation

You can install the package via composer:

composer require zentlix/twig-extensions

To enable the package in your Spiral Framework application, you will need to add the Zentlix\TwigExtensions\Bootloader\ExtensionsBootloader class to the list of bootloaders in your application:

protected const LOAD = [
    // ...
    \Zentlix\TwigExtensions\Bootloader\ExtensionsBootloader::class,
];

Note If you are using spiral-packages/discoverer, you don't need to register bootloader by yourself.

Available functions

path

Generate valid route URL using route name and set of parameters.

{{ path('user.edit', {'id': 1}) }}

Available filters

trans

Translates the given message.

{{ 'message' | trans }}

Available tests

of_type

Checks that the value is of the correct type. Available checks: array, bool, object, class, float, int, numeric, scalar, string.

{% if someVar is of_type('string') %}
    // ...
{% else %}
    // ...
{% endif %}

Testing

composer test
composer psalm
composer cs

License

The MIT License (MIT). Please see License File for more information.