File Coverage

blib/lib/XML/Toolkit/Builder/ClassTemplate.pm
Criterion Covered Total %
statement 16 16 100.0
branch 1 2 50.0
condition n/a
subroutine 6 6 100.0
pod 2 2 100.0
total 25 26 96.1


line stmt bran cond sub pod time code
1             package XML::Toolkit::Builder::ClassTemplate;
2             {
3             $XML::Toolkit::Builder::ClassTemplate::VERSION = '0.15';
4             }
5 2     2   1799 use Moose::Role;
  2         6  
  2         19  
6 2     2   23408 use Template;
  2         75388  
  2         81  
7 2     2   23 use namespace::autoclean;
  2         4  
  2         27  
8              
9             with qw(XML::Toolkit::Cmd::ClassTemplate);
10              
11             has tt_config => (
12             isa => 'HashRef',
13             is => 'ro',
14             lazy => 1,
15             default => sub {
16             {
17             OUTPUT_PATH => '.',
18             EVAL_PERL => 1,
19             POST_CHOMP => 1,
20             };
21             },
22             );
23              
24             has tt => (
25             isa => 'Template',
26             is => 'ro',
27             lazy_build => 1,
28             handles => [qw(error)],
29             );
30              
31 3     3   158 sub _build_tt { Template->new( $_[0]->tt_config ) }
32              
33             sub render {
34 3     3 1 229 return join '', map { $_[0]->render_class($_) } $_[0]->classes;
  5         30  
35             }
36              
37             sub render_class {
38 5     5 1 11 my ( $self, $class ) = @_;
39 5         10 my $output;
40 5 50       254 $self->tt->process( \$self->template, { meta => $class }, \$output )
41             || die $self->error;
42 5         211787 return $output;
43             }
44              
45             1;
46             __END__
47              
48             =head1 NAME
49              
50             XML::Toolkit::Builder::ClassTemplate
51              
52             =head1 VERSION
53              
54             version 0.15
55              
56             =head1 SYNOPSIS
57              
58             use XML::Toolkit::Builder::ClassTemplate;
59              
60             =head1 DESCRIPTION
61              
62             The XML::Toolkit::Builder::ClassTemplate class implements ...
63              
64             =head1 METHODS
65              
66             =head2 _build_template (method)
67              
68             Parameters:
69             none
70              
71             Arguments:
72             $_[0]
73              
74             Insert description of method here...
75              
76             =head2 render (method)
77              
78             Parameters:
79             none
80              
81             Insert description of method here...
82              
83             =head2 render_class (method)
84              
85             Parameters:
86             class
87              
88             Insert description of method here...