File Coverage

blib/lib/HiD/Processor/Handlebars.pm
Criterion Covered Total %
statement 33 33 100.0
branch 1 2 50.0
condition 1 3 33.3
subroutine 11 11 100.0
pod 2 2 100.0
total 48 51 94.1


line stmt bran cond sub pod time code
1             # ABSTRACT: Use Text::Handlebars to publish your HiD files
2              
3              
4             package HiD::Processor::Handlebars;
5             our $AUTHORITY = 'cpan:GENEHACK';
6             $HiD::Processor::Handlebars::VERSION = '1.991';
7 2     2   862 use Moose;
  2         4  
  2         13  
8             extends 'HiD::Processor';
9 2     2   12713 use namespace::autoclean;
  2         6  
  2         20  
10              
11 2     2   234 use 5.014; # strict, unicode_strings
  2         10  
12 2     2   13 use utf8;
  2         5  
  2         15  
13 2     2   54 use autodie;
  2         3  
  2         14  
14 2     2   9412 use warnings qw/ FATAL utf8 /;
  2         4  
  2         91  
15 2     2   11 use open qw/ :std :utf8 /;
  2         74  
  2         16  
16 2     2   317 use charnames qw/ :full /;
  2         2  
  2         13  
17              
18 2     2   1333 use Text::Handlebars;
  2         16394  
  2         412  
19              
20             has 'hb' => (
21             is => 'ro' ,
22             isa => 'Text::Handlebars' ,
23             required => 1 ,
24             );
25              
26             # FIXME this should really probably be a builder on the 'tt' attr
27             # ...which should be called something more generic
28             # ...and which should get args via a second attr that's required
29             sub BUILDARGS {
30 16     16 1 31 my $class = shift;
31              
32 16 50 33     75 my %args = ( ref $_[0] && ref $_[0] eq 'HASH' ) ? %{ $_[0] } : @_;
  16         66  
33              
34 16         159 return { hb => Text::Handlebars->new( %args ) };
35             }
36              
37             sub process {
38 199     199 1 1805 my( $self , $input_ref , $args , $output_ref ) = @_;
39              
40 199         4465 $$output_ref = $self->hb->render_string( $$input_ref , $args );
41              
42 199         1589777 return 1;
43             }
44              
45             __PACKAGE__->meta->make_immutable;
46             1;
47              
48             __END__
49              
50             =pod
51              
52             =encoding UTF-8
53              
54             =head1 NAME
55              
56             HiD::Processor::Handlebars - Use Text::Handlebars to publish your HiD files
57              
58             =head1 SYNOPSIS
59              
60             my $processor = HiD::Proccessor::Handlebars->new({ arg => $val });
61              
62             =head1 DESCRIPTION
63              
64             Wraps up a L<Text::Handlebars> object and allows it to be used during HiD publication.
65              
66             =head1 VERSION
67              
68             version 1.991
69              
70             =head1 AUTHOR
71              
72             John SJ Anderson <genehack@genehack.org>
73              
74             =head1 COPYRIGHT AND LICENSE
75              
76             This software is copyright (c) 2015 by John SJ Anderson.
77              
78             This is free software; you can redistribute it and/or modify it under
79             the same terms as the Perl 5 programming language system itself.
80              
81             =cut