File Coverage

blib/lib/App/Standup/Diary/Template.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 16 16 100.0


line stmt bran cond sub pod time code
1             package App::Standup::Diary::Template;
2              
3 2     2   14 use Object::Pad;
  2         3  
  2         27  
4 2     2   1560 use Mojo::Template;
  2         697246  
  2         19  
5 2     2   135 use App::Standup::Role::Date;
  2         4  
  2         89  
6 2     2   13 use App::Standup::Role::Project;
  2         5  
  2         618  
7              
8             class App::Standup::Diary::Template :does( Date ) :does( Project ) {
9              
10             method get_template {
11             my $diary_template = <<~'END_TEMPLATE';
12             # <%= $project_name %> <%= $today %>
13              
14             (C-c (C-o | C-d))
15             [PRIORITIES](<%= $priorities_date %>-00_priorities.md)
16              
17             - done
18             - todo
19             - blocking
20              
21             END_TEMPLATE
22              
23             return $diary_template;
24             }
25              
26             method render {
27             my $mt = Mojo::Template->new(auto_escape => 1);
28             my $month = $self->date->mon;
29             my $month_numeric = $self->date->mon < 10 ? "0$month" : $month;
30             return $mt->vars(1)->render(
31             $self->get_template, {
32             priorities_date => $self->date->year . '-' . $month_numeric,
33             project_name => $self->project_name,
34             today => $self->date->ymd
35             });
36             }
37             }
38              
39              
40             =head1 NAME
41              
42             App::Standup::Diary::Template - Diary entry markdown template
43              
44             =head1 SYNOPSIS
45              
46             my $template = App::Standup::Diary::Template->new(
47             date => $self->date,
48             project_name => $self->project_name
49             ));
50              
51             $template->render();
52              
53             =head1 DESCRIPTION
54              
55             Markdown template, for the daily needs.
56              
57             =head1 METHODS
58              
59             =head2 get_template()
60              
61             Return a un-interpreted template string respecting the
62             L engine syntax.
63              
64             =head2 render()
65              
66             Interpolate the template with the provided data.
67              
68             =cut