 +    };
 +    use warnings;
 +
-+    my $out;
 +    local *STDOUT;
 +    open STDOUT, '>', \$out or die "can't redirect stdout: $!";
++    warn "exec $file";
++
 +    require $file;
-+    return $out, $headers;
 +}
 +
 +sub slurp($) {

+use IO::Pipe;
+use JSON; our $JSON = JSON->new()->utf8(1);
+
+sub cgi_subprocess {
+    my ($self, $env, $file) = @_;
+    my $session = $env->{SESSION};
+    my $req     = Plack::Request->new($env);
+    my $headers = {};
+    no warnings;
+
+    local *::exit = sub {
+        die "EXIT?";
+    };
+    local *CGI::new = sub {
+        return Koha::Middleware::Session::Mock->new(
+            param => sub {

+        $in->{'type'}, $self,
+        $in->{'is_plugin'},
+    );
+
+    $template->param( LoginBranchname    => $self->{session}->param('branchname') );
+
+    #if ( $in->{'template_name'} !~ m/maintenance/ ) {
+    #    ( $user, $cookie, $sessionID, $flags ) = checkauth(
