Skip to content

emr/twig-compress

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

twig-compress

outputcompressorfortwigbutbetterthan{% spaceless %}

install

download repo

$ 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

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

examples

basic usage

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

output:

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

use with secure option

this does the same thing with {% spaceless %}

{% 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 %}

output:

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

About

output compressor extension for twig.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published