From e103c8d451c80a292ab2d1f0075bde843d47db69 Mon Sep 17 00:00:00 2001 From: Athos Ribeiro Date: Thu, 17 Dec 2015 10:57:09 -0200 Subject: [PATCH] refactoring subroutines --- lib/CoprStatus.pm | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/CoprStatus.pm b/lib/CoprStatus.pm index 83686e1..fcd5349 100644 --- a/lib/CoprStatus.pm +++ b/lib/CoprStatus.pm @@ -111,16 +111,7 @@ sub info2html { } sub build_html { - my $data = { - title => "SPB Copr Status", - table_entries => info2html() - }; - - my $template = Text::Template->new( - TYPE => 'FILE', - SOURCE => 'template.html.tt' - ); - + my ( $data, $template ) = @_; return $template->fill_in(HASH => $data); } @@ -131,10 +122,20 @@ our %ROUTING = ( ); sub serve_html { + my $data = { + title => "SPB Copr Status", + table_entries => info2html() + }; + + my $template = Text::Template->new( + TYPE => 'FILE', + SOURCE => 'template.html.tt' + ); + return [ '200', [ 'Content-Type' => 'text/html'], - [ build_html() ], + [ build_html($data, $template) ], ]; }; -- libgit2 0.21.2