File Coverage

blib/lib/Mojolicious/Plugin/Text/Minify.pm
Criterion Covered Total %
statement 14 14 100.0
branch 3 4 75.0
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 23 24 95.8


line stmt bran cond sub pod time code
1             package Mojolicious::Plugin::Text::Minify;
2              
3             # ABSTRACT: remove HTML indentation on the fly
4              
5 3     3   31432 use v5.16; # Mojolicious minimum version
  3         23  
6              
7 3     3   15 use Mojo::Base 'Mojolicious::Plugin';
  3         8  
  3         19  
8              
9 3     3   2145 use Text::Minify::XS v0.4.8 ();
  3         2023  
  3         512  
10              
11             our $VERSION = 'v0.2.2';
12              
13             sub register {
14 3     3 1 226 my ($self, $app, $conf) = @_;
15             $app->hook( after_render => sub {
16 3     3   52234 my ($c, $output, $format) = @_;
17              
18 3 100       14 return if $c->stash->{'mojox.no-minify'};
19              
20 2 50       29 if ($format eq "html") {
21 2         14 $$output = Text::Minify::XS::minify( $$output );
22             }
23 3         27 });
24              
25             }
26              
27             1;
28              
29             __END__