use My::Wrapper qw( wrap );
wrap( \&hello_world );
sub hello_world {
my %params = %{shift()};
my $T_ref = $params{T};
$T_ref->{msg} = "Hello World";
return;
}
####
use My::Wrapper qw( wrap );
wrap( \&foo_bar );
sub foo_bar {
my %params = %{shift()};
my $T_ref = $params{T};
$T_ref->{msg} = "Foo Bar";
return;
}
##
##
package My::Wrapper;
use strict;
use warnings;
use Exporter 'import';
@EXPORT_OK = qw( wrap );
use DBI;
use CGI;
use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
use HTML::Template;
use HTML::Entities;
use lib 'code';
use config;
## Security
$CGI::DISABLE_UPLOADS = 1; # no uploads!
$CGI::POST_MAX = 512*1024; # max 512k post
sub wrap {
my ( $code_ref ) = @_;
my $template = templates::loadTemplate('template');
my %T;
my $innerTemplate;
my $q = new CGI;
my $c;
$code_ref->({ q => $q,
T => \%T,
# etc.
});
## Filling in the template here
if($innerTemplate) {
# load the template in, put it into %T.
my $template = templates::loadTemplate('$innerTemplate');
$template->param($T{innerContent}) if $T{innerContent};
$T{content} = $template->output();
}
print $q->header();
$template->param(%T);
print $template->output();
}