blib/lib/auto/share/dist/Cmd-Dwarf/app/lib/Dwarf/Plugin/Text/Xslate.pm untested

filter: Statementstmt 0.0% 0 / 27 Branchbran n/a Conditioncond 0.0% 0 / 13 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 53 CC 1 SCAR 6.9
CC
1
Cov
0%
init
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package Dwarf::Plugin::Text::Xslate;
2 use Dwarf::Pragma;
3 use Dwarf::Util qw/add_method encode_utf8/;
4 use Dwarf::Util::Xslate qw/reproduce_line_feed/;
5 use Text::Xslate;
6  
7 sub init {
8 my ($class, $c, $conf) = @_;
9 $conf ||= {};
10 $conf->{path} ||= [$c->base_dir.'/tmpl'];
11 $conf->{cache_dir} ||= $c->base_dir.'/.xslate_cache';
12 $conf->{function} ||= {
13 lf => reproduce_line_feed,
14 };
15  
16 add_method($c, render => sub {
17 my ($self, $template, $vars, $options) = @_;
18 $vars ||= {};
19 $options ||= {};
20  
21 $self->call_trigger(BEFORE_RENDER => $self->handler, $self, $vars);
22  
23 my $tx = Text::Xslate->new(%$conf, %$options);
24 my $out = $tx->render($template, $vars);
25  
26 $self->call_trigger(AFTER_RENDER => $self->handler, $self, \$out);
27  
28 return encode_utf8($out);
29 });
30 }
31  
32 1;