outputcompressorfortwigbutbetterthan{% spaceless %}
download repo
$ composer require funcphp/twig-compress "dev-master"
// add extension to your twig engine
$twigEngine->addExtension(new \Func\Twig\CompressExtension());enable bundle
$bundles = [
...
new \Func\CompressBundle\FuncCompressBundle(),
...
];{% 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>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>