File Coverage

blib/lib/App/revealup/builder.pm
Criterion Covered Total %
statement 26 35 74.2
branch 4 10 40.0
condition 1 3 33.3
subroutine 6 6 100.0
pod 0 2 0.0
total 37 56 66.0


line stmt bran cond sub pod time code
1             package App::revealup::builder;
2 4     4   118575 use App::revealup::base;
  4         10  
  4         21  
3 4     4   667 use App::revealup::util;
  4         9  
  4         238  
4 4     4   24 use Path::Tiny qw/path/;
  4         4  
  4         133  
5 4     4   1707 use Text::MicroTemplate qw/render_mt/;
  4         11127  
  4         1342  
6              
7             has 'theme';
8             has 'theme_path';
9             has 'template';
10             has 'transition' => 'default';
11             has 'width' => 960;
12             has 'height' => 700;
13             has 'filename';
14              
15             sub build_html {
16 3     3 0 11 my $self = shift;
17 3 50 33     8 if ( !$self->filename || !path($self->filename)->exists ){
18 0         0 return;
19             }
20 3 50       124 if($self->theme) {
21 0 0       0 if ($self->theme !~ m!.+\.css$!){
22 0         0 my $name = $self->theme() . '.css';
23 0         0 $self->theme( $name );
24             }
25 0         0 my $p = path('.', $self->theme);
26 0 0       0 if(!$p->exists) {
27 0         0 $p = path('revealjs','dist','theme',$self->theme);
28 0         0 $self->theme_path($p);
29             }
30 0         0 $self->theme_path($p);
31             }
32 3         8 my $html = $self->render($self->filename);
33 3         9 return $html;
34             }
35              
36             sub render {
37 3     3 0 7 my ($self, $filename) = @_;
38 3         4 my $template;
39 3 100       7 if (!$self->template){
40 2         7 my $template_dir = App::revealup::util::share_path([qw/share templates/]);
41 2         38 $template = $template_dir->child('slide.html.mt');
42             } else {
43 1         3 $template = path($self->template);
44             }
45 3         101 my $content = $template->slurp_utf8();
46 3         2713 my $html = render_mt(
47             $content,
48             $filename,
49             $self->theme_path,
50             $self->transition,
51             { width => $self->width, height => $self->height },
52             )->as_string();
53 3         8112 return $html;
54             }
55              
56             1;