定制 dada-amater/latte-svg 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

dada-amater/latte-svg

Composer 安装命令:

composer require dada-amater/latte-svg

包简介

Latte macro to embed SVG from file into HTML

README 文档

README

<h1>
    Publications
    {svgFallback icon-group}
</h1>

Result HTML code IN IE may look like:

<h1>
    Publications
    <svg xmlns="..." class="..." ...>
        ... content of symbol-defs.svg file ...
    </svg>
</h1>

Example of icon

{svg bin, some-class, icon-group}

Result HTML code IN IE may look like:

<svg class="some-class" aria-hidden="true">
    <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#icon-bin"></use>
</svg>

Result in Chrome, FF, Opera may look like:

<svg class="some-class" aria-hidden="true">
    <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/images/svg/icon-group/symbol-defs.svg?v=1531909866#icon-bin"></use>
</svg>

Purpose

This is a single purpose helper library with a macro definition for Latte, the PHP templating engine. It loads SVG source file and embed it into HTML code in compile time.

Motivation for this is possibility to stylize SVG by CSS then. It is not (easily) possible with SVG linked as an image like <img src="icons/help.svg">.

Installation

Require library by Composer:

composer require dada-amater/latte-svg

Register extension in your config.neon and configure it:

extensions:
    latteSvg: DadaAmater\LatteSvg\Extension

latteSvg:
    baseDir: %wwwDir%
    wwwPathMask: 'images/svg/{group}/symbol-defs.svg'
    defaultGroup: base
    defaultIconClass: svg-icon
    iconNamePrefix: icon

Caveats & Limitations

Because svg is a macro, it is compiled into PHP only once and then is cached. So, when you change the macro configuration, probably in NEON, you have to purge Latte cache.

统计信息

  • 总下载量: 10.23k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 5
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-07-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固