jmf/twig-icon-bundle
Composer 安装命令:
composer require jmf/twig-icon-bundle
包简介
Symfony bundle for rendering pre-set icons in Twig templates.
README 文档
README
Symfony bundle providing a Twig icon() function backed by a configurable icon ID-to-CSS-class mapping.
Requirements
- PHP 8.3+
- Symfony 7.0 or 8.0
Installation
Install with Composer:
composer require jmf/twig-icon-bundle
Register the bundle in config/bundles.php if not using Symfony Flex:
<?php return [ // ... Jmf\Twig\Extension\Icon\JmfTwigIconBundle::class => ['all' => true], ];
Quick Start
Create config/packages/jmf_twig_icon.yaml (example for a usage with Material Symbols):
jmf_twig_icon: mapping: back: 'arrow_back' bookmark: 'check_box_outline_blank' bookmarked: 'check_box' create: 'add' delete: 'delete' download: 'download' link: 'link' print: 'print' read: 'visibility' save: 'save' search: 'search' swap: 'swap_horiz' unlink: 'link_off' update: 'edit' user: 'person' warning: 'warning' zoom_in: 'zoom_in'
Then use in Twig:
{{ icon('back') }}
Configuration Reference
jmf_twig_icon: # Optional prefix before the "icon" function name. Default: '' # Example: 'jmf_' registers 'jmf_icon' instead of 'icon'. prefix: '' # Twig template used to render the icon. Default: '@JmfIcon/material/icon.html.twig' template_path: '@JmfIcon/material/icon.html.twig' # Map of icon IDs to their CSS class names. mapping: back: 'arrow_back' bookmark: 'check_box_outline_blank' bookmarked: 'check_box' create: 'add' delete: 'delete' download: 'download'
A sample configuration file is available in the samples/ directory.
License
MIT
统计信息
- 总下载量: 15
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: mit
- 更新时间: 2026-05-29