26/12
2017
dev-master
9999999-devOutput compressor for twig
The Requires
The Development Requires
Wallogit.com
2017 © Pedro Peláez
Output compressor for twig
outputcompressorfortwigbutbetterthan{% spaceless %}, (*1)
download repo, (*2)
$ composer require funcphp/twig-compress "dev-master"
// add extension to your twig engine $twigEngine->addExtension(new \Func\Twig\CompressExtension());
enable bundle, (*3)
$bundles = [
...
new \Func\CompressBundle\FuncCompressBundle(),
...
];
{% 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>
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>
Output compressor for twig