2017 © Pedro Peláez
 

library twig-compress

Output compressor for twig

image

funcphp/twig-compress

Output compressor for twig

  • Tuesday, December 26, 2017
  • by emreakinci
  • Repository
  • 1 Watchers
  • 0 Stars
  • 26 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 333 % Grown

The README.md

twig-compress

outputcompressorfortwigbutbetterthan{% spaceless %}, (*1)

install

download repo, (*2)

$ composer require funcphp/twig-compress "dev-master"
without symfony:
// add extension to your twig engine
$twigEngine->addExtension(new \Func\Twig\CompressExtension());
with symfony:

enable bundle, (*3)

$bundles = [
    ...
    new \Func\CompressBundle\FuncCompressBundle(),
    ...
];

examples

basic usage

{% compress %}
<html>
    <head>
        <style>
            body {
                background: #fcc200;
            }
        </style>
        <script>
            alert('hello')
        </script>
    </head>
</html>
{% endcompress %}

output:, (*4)

<html><head><style> body { background: #fcc200; } </style><script> alert('hello') </script></head></html>

use with secure option

this does the same thing with {% spaceless %}, (*5)

{% compress not secure %}
<html>
    <head>
        <style>
            body {
                background: #fcc200;
            }
        </style>
        <script>
            alert('hello')
        </script>
    </head>
</html>
{% endcompress %}

you can use {% compress secure=false %} instead of {% compress not secure %}, (*6)

output:, (*7)

<html><head><style>
            body {
                background: #fcc200;
            }
        </style><script>
            alert('hello')
        </script></head></html>

The Versions

26/12 2017

dev-master

9999999-dev

Output compressor for twig

  Sources   Download

The Requires

 

The Development Requires