定制 m1/twig-asset-rev-extension 二次开发

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

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

m1/twig-asset-rev-extension

最新稳定版本:1.1.1

Composer 安装命令:

composer require m1/twig-asset-rev-extension

包简介

Twig Asset Rev Extension adds a asset_rev twig filter so you can use asset revisioning from files, perfect for use with gulp-rev or grunt-rev

README 文档

README

Author Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

Twig Asset Rev Extension adds a asset_rev twig filter so you can use asset revisioning from files, perfect for use and tested with gulp-rev/gulp-rev-all or grunt-rev

Requirements

TwigAssetRevExtension requires PHP version 5.3+.

Install

Via Composer

$ composer require m1/twig-asset-rev-extension

Usage

TwigAssetRevExtension works like other twig extensions, just add the extension using $twig->addExtension().

Use \M1\TwigAssetRevExtension\TwigAssetRevExtension;

$assets = json_decode(file_get_contents('rev-manifest.json'), true);
$asset_rev = new TwigAssetRevExtension($assets);
$twig->addExtension($asset_rev);

example.twig:

<link href='{{"css/app.css"|asset_rev}}' rel='stylesheet'>

rev-manifest.json:

{
  "css/app.css": "css/app.bd6efcb01bc3.css",
  "css/app.min.css": "css/app.min.9f8d3d255c1f.css",
}

Symfony usage

You can register the extension automatically in Symfony via app/config/services.yml.

twig.extension.asset_rev:
  class: M1\TwigAssetRevExtension\TwigAssetRevExtension
  arguments: [ "%kernel.root_dir%/../web/js/manifest.json", false ]
  tags:
    - { name: twig.extension }

Setup

new TwigAssetRevExtension(mixed $assets [, bool $minified = true ] )

Parameters

assets

The path to the JSON file, or the array of assets and rev'd assets, an example:

array(
  "css/app.css" => "css/app.bd6efcb01bc3.css",
  "css/app.min.css" => "css/app.min.9f8d3d255c1f.css",
  "js/app.admin.js" => "js/app.admin.96b3cc15df52.js",
  "js/app.admin.min.js" => "js/app.admin.min.dbdc6d8e2114.js",
  "js/app.admin.plugins.js" => "js/app.admin.plugins.927a9b50dd18.js",
  "js/app.admin.plugins.min.js" => "js/app.admin.plugins.min.283a1a903f4a.js",
  "img/image-jpg.jpg" => "img/image-jpg.219a48cfe072.jpg",
  "img/image-png.png" => "img/image-png.1691620d298a.png",
  "img/image-gif.gif" => "img/image-gif.bcd9f17c5cf8.png"
)

If using gulp-rev or gulp-rev-all this is just the contents of rev-manifest.json - parsing the json file with json_decode(file_get_contents('rev-manifest.json'), true);. You should probably cache this result though so you don't have to read the file every request.

minified

When true this means that TwigAssetRevExtension will pass back minified assets if they're available. Twig debug mode or Silex debug mode override this and it won't pass back minified assets in development.

Change log

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please email hello@milescroxford.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-01-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固