e-monsite / color-twig-extension
使用twig操作颜色
v2.2.1
2021-10-05 08:19 UTC
Requires
- php: ^7.3|^8.0
- marcovo/shade-blend-convert: ^1.0
- mikealmond/color: ^0.1.3
- twig/twig: ^2.12|^3.0
Requires (Dev)
- phpunit/phpunit: ^8.4
README
安装
composer require e-monsite/color-twig-extension
如果你在Symfony上,请将此捆绑包添加到你的捆绑包中
// config/bundles.php return [ Emonsite\ColorTwigExtension\ColorExtensionBundle::class => ['all' => true], ];
用法
这里有一些示例
{{ 'rgb(138, 7, 7)' | darken(20) }} {{ '#8a0707' | lighten(40) }} {{ 'green' | alpha(0.5) }} {% if myColor is dark %} ... {% endif %} {% if myColor2 is light %} ... {% endif %}