Template::Plugin::Filter::MinifyHTML - HTML minification filter for Template Toolkit
[% USE Filter.MinifyHTML( comments => 1, html5 => 1 ) %]
[% FILTER minify_html %]
...Your html content here...
[% END %]
This is a Template Toolkit filter which uses a few quick and nasty regexes to minify HTML source code. It’s built upon the idea/workings
of the default ’collapse’ filter, but adds a little spice of its own into the mix, removing HTML comments and a few other bits and
Be sure to [% USE Filter.MinifyHTML %] in your template, then you're able to wrap [% FILTER minify_html %][% END %] around blocks that you would like to minify.
Filter.MinyfyHTML can currently take two arguments - comments and html5.
If comments is set to a truesy value it will remove any HTML comments it finds (). It shouldn't affect any conditional comments in your markup (ie. ).
If html5 is truesy, then it will remove the trailing slash on self-closing elements (
, , etc). BUYER BEWARE This filter does not check for or acknowledge the existence or importance of tags such as