2017 © Pedro Peláez
 

library html-compress-twig

Twig extension for compressing HTML

image

voku/html-compress-twig

Twig extension for compressing HTML

  • Saturday, December 23, 2017
  • by voku
  • Repository
  • 1 Watchers
  • 2 Stars
  • 4,466 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 7 Forks
  • 0 Open issues
  • 6 Versions
  • 17 % Grown

The README.md

Build Status Coverage Status Scrutinizer Code Quality Codacy Badge SensioLabsInsight Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

:clamp: HtmlMin for Twig: HTML Compressor and Minifier

Description

A Twig extension for voku/HtmlMin., (*2)

Currently supported Twig features are:, (*3)

  • Tag
    • {% htmlcompress %} <foo>bar</foo> {% endhtmlcompress %}
  • Function
    • {{ htmlcompress(' <foo>bar</foo>') }}
  • Filter, (*4)

    • {{ ' <foo>bar</foo>' | htmlcompress }}
  • Installation, (*5)

  • Usage
  • History
  • License

Installation

  1. Install and use composer in your project.
  2. Require this package via composer:
composer require voku/html-compress-twig

Usage

First register the extension with Twig:, (*6)

use voku\helper\HtmlMin;
use voku\twig\MinifyHtmlExtension;

$twig = new \Twig\Environment($loader);
$minifier = new HtmlMin();
$twig->addExtension(new MinifyHtmlExtension($minifier));

Register extension in symfony 4

Specifying HtmlMin is needed for the autowiring., (*7)

    voku\helper\HtmlMin:
        tags:
            - { name: HtmlMin }

    voku\twig\MinifyHtmlExtension:
        arguments:
            $forceCompression: false
        tags:
            - { name: twig.extension }

Then use it in your templates:, (*8)

{% htmlcompress %} <foo>bar</foo> {% endhtmlcompress %}
{{ htmlcompress(' <foo>bar</foo>') }}
{{ ' <foo>bar</foo>' | htmlcompress }}

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

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

$twig->addExtension(new MinifyHtmlExtension($minifier, true));

History

See CHANGELOG for the full history of changes., (*11)

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., (*12)

The Versions

23/12 2017

dev-master

9999999-dev

Twig extension for compressing HTML

  Sources   Download

ISC

The Requires

 

The Development Requires

twig extension html minify compress

23/12 2017

3.0.0

3.0.0.0

Twig extension for compressing HTML

  Sources   Download

ISC

The Requires

 

The Development Requires

twig extension html minify compress

03/12 2017

2.0.0

2.0.0.0

Twig extension for compressing HTML

  Sources   Download

ISC

The Requires

 

The Development Requires

twig extension html minify compress

18/03 2017

1.0.2

1.0.2.0

Twig extension for compressing HTML

  Sources   Download

ISC

The Requires

 

The Development Requires

twig extension html minify compress

18/03 2017

1.0.1

1.0.1.0

Twig extension for compressing HTML

  Sources   Download

ISC

The Requires

 

The Development Requires

twig extension html minify compress

18/03 2017

1.0.0

1.0.0.0

Twig extension for compressing HTML

  Sources   Download

ISC

The Requires

 

The Development Requires

twig extension html minify compress