]> git.evergreen-ils.org Git - working/NCIPServer.git/blob - lib/NCIP/Handler.pm
Responding better now
[working/NCIPServer.git] / lib / NCIP / Handler.pm
1 package NCIP::Handler;
2 #
3 #===============================================================================
4 #
5 #         FILE: Hander.pm
6 #
7 #  DESCRIPTION:
8 #
9 #        FILES: ---
10 #         BUGS: ---
11 #        NOTES: ---
12 #       AUTHOR: Chris Cormack (rangi), chrisc@catalyst.net.nz
13 # ORGANIZATION: Koha Development Team
14 #      VERSION: 1.0
15 #      CREATED: 19/09/13 10:43:14
16 #     REVISION: ---
17 #===============================================================================
18
19 use Modern::Perl;
20 use Object::Tiny qw{ type namespace ils templates };
21 use Module::Load;
22 use Template;
23
24 sub new {
25     my $class    = shift;
26     my $params   = shift;
27     my $subclass = __PACKAGE__ . "::" . $params->{type};
28     load $subclass || die "Can't load module $subclass";
29     my $self = bless {
30         type      => $params->{type},
31         namespace => $params->{namespace},
32         ils       => $params->{ils},
33         templates => $params->{template_dir}
34     }, $subclass;
35     return $self;
36 }
37
38 sub render_output {
39     my $self         = shift;
40     my $templatename = shift;
41
42     my $vars     = shift;
43     my $template = Template->new(
44         { INCLUDE_PATH => $self->templates, } );
45     my $output;
46     $template->process( $templatename, $vars, \$output );
47     return $output;
48 }
49 1;