funcphp / twig-compress
Output compressor for twig
Installs: 13 777
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 1
Open Issues: 0
pkg:composer/funcphp/twig-compress
Requires
- twig/twig: *
Requires (Dev)
- phpunit/phpunit: ^6.5
This package is not auto-updated.
Last update: 2025-12-16 23:38:03 UTC
README
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>