File Coverage

blib/lib/App/revealup/builder.pm
Criterion Covered Total %
statement 23 32 71.8
branch 2 8 25.0
condition 1 3 33.3
subroutine 6 6 100.0
pod 0 2 0.0
total 32 51 62.7


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