e-monsite/color-twig-extension

Manipulate colors with twig

v2.2.1 2021-10-05 08:19 UTC

This package is auto-updated.

Last update: 2024-05-05 13:53:58 UTC


README

install

composer require e-monsite/color-twig-extension

Then add the bundle to yours bundles if you are on Symfony:

// config/bundles.php
return [
    Emonsite\ColorTwigExtension\ColorExtensionBundle::class => ['all' => true],
];

Usage

There is some examples:

{{ 'rgb(138, 7, 7)' | darken(20) }}
{{ '#8a0707' | lighten(40) }}
{{ 'green' | alpha(0.5) }}
{% if myColor is dark %} ... {% endif %}
{% if myColor2 is light %} ... {% endif %}