承接 nochso/html-compress-twig 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

nochso/html-compress-twig

最新稳定版本:2.0.1

Composer 安装命令:

composer require nochso/html-compress-twig

包简介

Twig extension for compressing HTML and inline CSS/Javascript

README 文档

README

Latest Stable Version License Build Status

A Twig extension for WyriHaximus/HtmlCompress.

Currently supported Twig features are:

  • Tag
    • {% htmlcompress %} ... {% endhtmlcompress %}
  • Function
    • {{ htmlcompress('some html') }}
  • Filter
    • {{ content|markdown|htmlcompress }}

Any HTML, inline CSS and Javascript will be compressed.

Installation

  1. Install and use composer in your project.

  2. Require this package via composer:

    composer require nochso/html-compress-twig

Usage

First register the extension with Twig:

$twig = new Twig_Environment($loader); $twig->addExtension(new \nochso\HtmlCompressTwig\Extension());

Then use it in your templates:

{% htmlcompress %}{% endhtmlcompress %} {{ htmlcompress('<ul> <li>') }} {{ '<ul> <li>'|htmlcompress }} 

Compression is disabled by Twig's debug setting. This is to make development easier, however you can always override it.

The constructor of this extension takes a boolean parameter $forceCompression. When true, this will force compression regardless of Twig's debug setting. It defaults to false when omitted.

// Enable compression regardless of Twig's debug setting $twig->addExtension(new \nochso\HtmlCompressTwig\Extension(true));

History

See CHANGELOG for the full history of changes.

License

This project is licensed under the ISC license which is MIT/GPL compatible and FSF/OSI approved. See the LICENSE file for the full license text.

统计信息

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

GitHub 信息

  • Stars: 79
  • Watchers: 4
  • Forks: 17
  • 开发语言: PHP

其他信息

  • 授权协议: ISC
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固