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