Miril/Template/HTML/Template.pm untested

filter: Statementstmt 0.0% 0 / 38 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 49 CC 1 SCAR 6.9
CC
1
Cov
0%
load
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package Miril::Template::HTML::Template;
2
3 use strict;
4 use warnings;
5 use autodie;
6
7 use base 'Miril::Template::Abstract';
8
9 use HTML::Template::Pluggable;
10 use HTML::Template::Plugin::Dot;
11 use File::Spec::Functions qw(catfile);
12 use Try::Tiny qw(try catch);
13 use Miril::Exception;
14
15 sub load {
16 my $self = shift;
17 my %options = @_;
18 my $tmpl;
19
20 try
21 {
22 $tmpl = HTML::Template::Pluggable->new(
23 filename => catfile($self->tmpl_path, $options{name}),
24 path => $self->{tmpl_path},
25 die_on_bad_params => 0,
26 global_vars => 1,
27 case_sensitive => 1,
28 );
29 }
30 catch
31 {
32 Miril::Exception->throw(
33 message => "Could not open template file",
34 errorvar => $_,
35 );
36 };
37
38 $tmpl->param( %{ $options{params} } );
39
40 my $output = $tmpl->output;
41 # BOM's mess up with html, see: http://www.w3.org/International/questions/qa-utf8-bom
42 # this is a hack and will probably break UTF-16 and UTF-32
43 # I am not really sure why BOM's get added for UTF-8 files ...
44 $output =~ s/\xEF\xBB\xBF//g;
45
46 return $output;
47 }
48
49 1;
50