[Catalyst] Compress HTML

Stefan catalyst at s.profanter.me
Thu Sep 8 22:14:12 GMT 2011


> Guess you should pass a ref to $rendered to minify(), not the string
itself.

Yes!!! Thanks a lot! This did it. Here is the complete code for others:

use HTML::Packer;
use JavaScript::Packer;
use CSS::Packer;

my $html_packer = HTML::Packer->init();

sub process {
            my ( $self, $c ) = @_;
            my $rendered = $self->render($c, $c->stash->{template});
            my $opts = {
                        remove_comments => 1,
                        remove_newlines => 1,
                        html5 => 1,
                        do_javascript => 'best',
                        do_stylesheet => 'minify',
            };
            $html_packer->minify( \$rendered, $opts );
            $c->response->body($rendered);
}

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20110909/9200e4ef/attachment.htm


More information about the Catalyst mailing list