All Projects → nochso → Html Compress Twig

nochso / Html Compress Twig

Licence: other
Twig extension for compressing HTML and inline CSS/JS using WyriHaximus/HtmlCompress

Projects that are alternatives of or similar to Html Compress Twig

Awesome Twig
A curated list of amazingly awesome Twig extensions, snippets and tutorials
Stars: ✭ 63 (-12.5%)
Mutual labels:  twig, twig-extension
Twig Cache Extension
Stars: ✭ 67 (-6.94%)
Mutual labels:  twig, twig-extension
framework
Cygnite PHP Framework- A Modern Toolkit For Web Developers
Stars: ✭ 43 (-40.28%)
Mutual labels:  composer, twig
twig-translation
A Twig Translation Extension
Stars: ✭ 15 (-79.17%)
Mutual labels:  twig, twig-extension
Leanify
lightweight lossless file minifier/optimizer
Stars: ✭ 694 (+863.89%)
Mutual labels:  minify, compression
cache-extra
Template fragment cache support for Twig
Stars: ✭ 24 (-66.67%)
Mutual labels:  twig, twig-extension
oc-twigextensions-plugin
Twig extensions plugin for OctoberCMS
Stars: ✭ 17 (-76.39%)
Mutual labels:  twig, twig-extension
DrupalTwigFood
Useful functions, filters for twig @ Drupal 8
Stars: ✭ 1 (-98.61%)
Mutual labels:  twig, twig-extension
Twig Extra Bundle
The Twig bundle for official extra extensions
Stars: ✭ 389 (+440.28%)
Mutual labels:  twig, twig-extension
Compress Images
Minify size your images. Image compression with extension: jpg/jpeg, svg, png, gif. NodeJs
Stars: ✭ 331 (+359.72%)
Mutual labels:  minify, compression
phpPgAdmin6
PHP7+ Based administration tool for PostgreSQL 9.3+
Stars: ✭ 45 (-37.5%)
Mutual labels:  composer, twig
Fmbbcodebundle
🔠 BBCode bundle for Symfony projects
Stars: ✭ 56 (-22.22%)
Mutual labels:  twig, twig-extension
PhpStorm-Live-Templates-Craft-CMS
PhpStorm Live Templates for Craft CMS
Stars: ✭ 34 (-52.78%)
Mutual labels:  twig, twig-extension
joomla-twig
Twig 2.0 & Twig extensions integration for Joomla! https://phproberto.github.io/joomla-twig/
Stars: ✭ 25 (-65.28%)
Mutual labels:  twig, twig-extension
markdown-extra
Markdown extension for Twig
Stars: ✭ 83 (+15.28%)
Mutual labels:  twig, twig-extension
packtag
A JSP Taglib for delivering minified, combined and gzip-compressed resources (JavaScript and CSS).
Stars: ✭ 22 (-69.44%)
Mutual labels:  compression, minify
yaf-example
A example of yaf
Stars: ✭ 53 (-26.39%)
Mutual labels:  composer, twig
cssinliner-extension
[DEPRECATED] CSS inliner support for Twig
Stars: ✭ 30 (-58.33%)
Mutual labels:  twig, twig-extension
time-ago-bundle
Provides a simple twig filter for expressing time difference in words.
Stars: ✭ 13 (-81.94%)
Mutual labels:  twig, twig-extension
Html Extra
HTML extension for Twig
Stars: ✭ 24 (-66.67%)
Mutual labels:  twig, twig-extension

nochso/html-compress-twig extension

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].