funcphp / twig-compress
Output compressor for twig
Installs: 10 757
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 1
Open Issues: 0
Requires
- twig/twig: *
Requires (Dev)
- phpunit/phpunit: ^6.5
This package is not auto-updated.
Last update: 2025-05-06 20:51:15 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>