package Standup::Diary::Template;

use Object::Pad;
use Mojo::Template;
use Standup::Role::Date;
use Standup::Role::Project;

class Standup::Diary::Template :does( Date ) :does( Project ) {

  method get_template {
    my $diary_template = <<~'END_TEMPLATE';
      # <%= $project_name %> <%= $today %>

      (C-c (C-o | C-d))
      [PRIORITIES](<%= $priorities_date %>-00_priorities.md)

      - done
      - todo
      - blocking

      END_TEMPLATE

    return $diary_template;
  }

  method render {
    my $mt = Mojo::Template->new(auto_escape => 1);
    my $month = $self->date->mon;
    my $month_numeric = $self->date->mon < 10 ? "0$month" : $month;
    return $mt->vars(1)->render(
      $self->get_template, {
        priorities_date => $self->date->year . '-' . $month_numeric,
        project_name    => $self->project_name,
        today           => $self->date->ymd
      });
  }
}


=head1 NAME

Standup::Diary::Template - Manage diary entry markdown template

=head1 SYNOPSIS

=head1 DESCRIPTION

=head1 METHODS

=head2 get_template()

=head2 render()

=cut
