| 1 | # ABSTRACT: Use Text::Handlebars to publish your HiD files | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | package HiD::Processor::Handlebars; | ||||||||||||||||||||||||||||
| 5 | 2 | $HiD::Processor::Handlebars::VERSION = '1.5'; | |||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 2 | extends 'HiD::Processor'; | |||||||||||||||||||||||||||
| 8 | 2 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use 5.014; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use utf8; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use autodie; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use warnings qw/ FATAL utf8 /; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 2 | ▶ | use open qw/ :std :utf8 /; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use charnames qw/ :full /; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 2 | ▶ | use feature qw/ unicode_strings /; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 2 | ▶ | use Text::Handlebars; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 2 | 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 | 17 | ▶ | my $class = shift; | ||||||||||||||||||||||||||
|
Subroutine
BUILDARGS: called CC=3 SCAR=12.0
Pod
documented
| |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 17 | ▶ | my %args = ( ref $_[0] && ref $_[0] eq 'HASH' ) ? %{ $_[0] } : @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $_[0] and ref $_[0] eq "HASH"
MC/DC0%0/2
ref $_[0] and ref $_[0] eq "HASH"
ref $_[0]
ref $_[0] eq "HASH"
Truth table33%1/3
A and B
A= ref $_[0]B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 17 | return { hb => Text::Handlebars->new( %args ) }; | |||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | sub process { | ||||||||||||||||||||||||||||
| 38 | 72 | ▶ | my( $self , $input_ref , $args , $output_ref ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
process: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 72 | $$output_ref = $self->hb->render_string( $$input_ref , $args ); | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 72 | return 1; | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 2 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 46 | 2 | 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.5 | ||||||||||||||||||||||||||||
| 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) 2014 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 | ||||||||||||||||||||||||||||