spaze/svg-icons-latte

Latte 模板系统自定义 SVG 图标标签

v1.0.3 2023-09-20 00:55 UTC

This package is auto-updated.

Last update: 2024-09-20 03:15:25 UTC


README

自定义 {icon} 标签将嵌入从外部文件加载的 SVG 图标。

安装

composer require spaze/svg-icons-latte

需要 PHP 8.1+

注册 Nette 扩展,例如:

extensions:
	svgIcons: Spaze\SvgIcons\NetteExtension

这也会自动注册 Latte 扩展本身。

配置

svgIcons:
	iconsDir: '../../node_modules/humbleicons/icons'
	cssClass: 'humbleicons'
  • iconsDir 是 SVG 图标文件所在的目录路径,例如 Humbleicons@Zraly 提供(必需)
  • cssClass 定义将添加到根 <svg> 元素的 CSS 类(可选)

使用方法

{icon wifi} 将被替换为从 iconsDir 中加载的 wifi.svg 的内容。

您还可以添加额外的 CSS 类:{icon wifi class => foo, class => bar} 将将额外的 CSS 类 foobar 添加到根 <svg> 元素。

根据上述配置,生成的标签将看起来像 <svg class="humbleicons foo bar" ...>