Diary/Template.pm untested

filter: Statementstmt 0.0% 0 / 20 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod n/a totaltotal 0.0% 0 / 26 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package App::Standup::Diary::Template;
2  
3 use Object::Pad;
4 use Mojo::Template;
5 use App::Standup::Role::Date;
6 use App::Standup::Role::Project;
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<Mojo::Template|https://docs.mojolicious.org/Mojo/Template> engine syntax.
63  
64 =head2 render()
65  
66 Interpolate the template with the provided data.
67  
68 =cut