marcw / twig-heroicons
Heroicons 的非官方 Twig 集成
1.0.1
2021-04-10 14:39 UTC
Requires
- twig/twig: ^3.3
Requires (Dev)
- phpunit/phpunit: ^9.5
- symfony/framework-bundle: ^5.0
README
此包为 Twig 提供Heroicons集成。
安装
使用 composer
composer require marcw/twig-heroicons
Symfony
要使用此扩展,无需进行任何额外操作。
Twig
如果您直接使用 Twig,在使用扩展之前请先注册它
<?php use MarcW\Heroicons\Twig\HeroiconsExtension; use Twig\Environment; $twig = new Environment(/* ... */); $twig->addExtension(new HeroiconsExtension());
用法
此扩展提供了一个 heroicon
函数,用于输出图标 SVG。
{# function signature #} {{ heroicon(icon, class, style) }} {# the default style is 'solid' #} {{ heroicon('academic-cap') }} {# use the 'outline' style #} {{ heroicon('academic-cap', '', 'outline') }} {# Add a custom class to the SVG #} {{ heroicon('academic-cap', 'text-green-200', 'outline') }}
许可协议
此库采用 MIT 许可协议。