| 1 | package Plack::Middleware::Bootstrap; | ||||||||||||
| 2 | 2 | ▶ | use 5.008001; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | |||||||||||||
| 6 | 2 | our $VERSION = "0.08"; | |||||||||||
| 7 | |||||||||||||
| 8 | 2 | ▶ | use parent qw(Plack::Middleware); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 2 | ▶ | use Plack::Util (); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | 2 | ▶ | use Plack::Response; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | |||||||||||||
| 12 | 2 | ▶ | use Text::MicroTemplate::DataSection qw(); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 13 | 2 | ▶ | use HTML::TreeBuilder::XPath; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 14 | |||||||||||||
| 15 | 6 | ▶ | sub call { | ||||||||||
|
Subroutine
call: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 16 | 6 | my ($self, $env) = @_; | |||||||||||
| 17 | |||||||||||||
| 18 | Plack::Util::response_cb( | ||||||||||||
| 19 | $self->app->($env), | ||||||||||||
| 20 | 6 | ▶ | sub { | ||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=17.9
| |||||||||||||
| 21 | 6 | my $res = shift; | |||||||||||
| 22 | |||||||||||||
| 23 | 6 | my $plack_res = Plack::Response->new(@$res); | |||||||||||
| 24 | 6 | ▶ | return unless $plack_res->content_type =~ /\Atext\/html/; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 25 | 5 | ▶ | return if $plack_res->content_encoding; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 26 | |||||||||||||
| 27 | 4 | my $content; | |||||||||||
| 28 | 4 | ▶ | Plack::Util::foreach($res->[2] || [], sub { $content .= $_[0] }); | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.2
Condition50%1/2
$res->[2] || []
MC/DC0%0/1
$res->[2] || []
$res->[2]
Truth table50%1/2
A
A= $res->[2]
| |||||||||||||
| 29 | |||||||||||||
| 30 | 4 | my $tree = HTML::TreeBuilder::XPath->new(); | |||||||||||
| 31 | 4 | $tree->ignore_unknown(0); | |||||||||||
| 32 | 4 | $tree->store_comments(1); | |||||||||||
| 33 | 4 | $tree->parse_content($content); | |||||||||||
| 34 | |||||||||||||
| 35 | 4 | ▶ | my $head = join "\n", map { ref($_) ? $_->as_HTML(q{&<>'"}, '', {}) : $_ } $tree->findnodes('//head')->[0]->content_list; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 36 | 4 | ▶ | my $body = join "\n", map { ref($_) ? $_->as_HTML(q{&<>'"}, '', {}) : $_ } $tree->findnodes('//body')->[0]->content_list; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 37 | |||||||||||||
| 38 | 4 | my $renderer = Text::MicroTemplate::DataSection->new( | |||||||||||
| 39 | escape_func => undef | ||||||||||||
| 40 | ); | ||||||||||||
| 41 | |||||||||||||
| 42 | # render_mt returns Text::MicroTemplate::EncodedString. | ||||||||||||
| 43 | 4 | $res->[2] = [ $renderer->render_mt('template.mt', $head, $body).q() ]; | |||||||||||
| 44 | |||||||||||||
| 45 | 4 | Plack::Util::header_remove($res->[1], 'Content-Length'); | |||||||||||
| 46 | 6 | }); | |||||||||||
| 47 | } | ||||||||||||
| 48 | |||||||||||||
| 49 | 2 | 1; | |||||||||||
| 50 | __DATA__ | ||||||||||||