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.99';
7 2     2   1321 use Moose;
  2         6  
  2         22  
8             extends 'HiD::Processor';
9 2     2   16648 use namespace::autoclean;
  2         4  
  2         21  
10              
11 2     2   226 use 5.014; # strict, unicode_strings
  2         8  
12 2     2   11 use utf8;
  2         4  
  2         14  
13 2     2   46 use autodie;
  2         4  
  2         16  
14 2     2   9646 use warnings qw/ FATAL utf8 /;
  2         6  
  2         109  
15 2     2   12 use open qw/ :std :utf8 /;
  2         91  
  2         19  
16 2     2   332 use charnames qw/ :full /;
  2         5  
  2         18  
17              
18 2     2   1642 use Text::Handlebars;
  2         17823  
  2         475  
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 47 my $class = shift;
31              
32 16 50 33     119 my %args = ( ref $_[0] && ref $_[0] eq 'HASH' ) ? %{ $_[0] } : @_;
  16         94  
33              
34 16         219 return { hb => Text::Handlebars->new( %args ) };
35             }
36              
37             sub process {
38 199     199 1 2260 my( $self , $input_ref , $args , $output_ref ) = @_;
39              
40 199         5089 $$output_ref = $self->hb->render_string( $$input_ref , $args );
41              
42 199         1757941 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.99
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