File Coverage

blib/lib/Template/Plugin/HashMerge.pm
Criterion Covered Total %
statement 15 15 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 20 20 100.0


line stmt bran cond sub pod time code
1             package Template::Plugin::HashMerge;
2              
3 3     3   166889 use strict;
  3         6  
  3         103  
4 3     3   13 use warnings;
  3         5  
  3         107  
5              
6             require Template::Plugin::Procedural;
7 3     3   2889 use Hash::Merge;
  3         7552  
  3         143  
8              
9 3     3   103 use vars qw($VERSION @ISA);
  3         6  
  3         217  
10             $VERSION = '0.01';
11             @ISA = qw(Template::Plugin::Procedural);
12              
13             =head1 NAME
14              
15             Template::Plugin::HashMerge - TT2 plugin to use Hash::Merge
16              
17             =head1 SYNOPSIS
18              
19             [% USE HashMerge %]
20             [% a = {
21             foo => 1,
22             bar => [ 'a', 'b', 'e' ],
23             baz => {
24             bob => 'alice',
25             },
26             };
27             b = {
28             foo => 2,
29             bar => [ 'c', 'd' ],
30             baz => {
31             ted => 'margeret',
32             },
33             };
34             HashMerge.set_behaviour( 'RIGHT_PRECEDENT' );
35             c = HashMerge.merge( a, b ); %]
36              
37             =head1 DESCRIPTION
38              
39             L plugin HashMerge provides the L functions
40             C and C to be used within templates.
41              
42             This can be useful in all cases a template works directly on data - e.g.
43             when processing results from a query using L and join the
44             result with results from derived queries.
45              
46             =head1 USAGE
47              
48             [% USE HashMerge %]
49             [% HashMerge.set_behaviour( );
50             result = HashMerge.merge( hash1, hash2 ); %]
51              
52             Detailed function description and default behaviours are available in
53             L.
54              
55             If you prefer to use virtual hash methods, see L.
56              
57             =head1 FUNCTIONS PROVIDED
58              
59             =head2 merge
60              
61             =head2 get_behavior
62              
63             =head2 set_behavior
64              
65             =head2 specify_behavior
66              
67             =cut
68              
69 3     3   18 no strict 'refs';
  3         7  
  3         433  
70              
71             *merge = *{'Hash::Merge::merge'}{CODE} if( defined( *{'Hash::Merge::merge'}{CODE} ) );
72             *get_behavior = *{'Hash::Merge::get_behavior'}{CODE} if( defined( *{'Hash::Merge::get_behavior'}{CODE} ) );
73             *set_behavior = *{'Hash::Merge::set_behavior'}{CODE} if( defined( *{'Hash::Merge::set_behavior'}{CODE} ) );
74             *specify_behavior = *{'Hash::Merge::specify_behavior'}{CODE} if( defined( *{'Hash::Merge::specify_behavior'}{CODE} ) );
75              
76             =head1 INSTALL
77              
78             To install this module, use
79              
80             perl Build.PL
81             ./Build
82             ./Build test
83             ./Build install
84              
85             =head1 BUGS & LIMITATIONS
86              
87             None known.
88              
89             =head1 SUPPORT
90              
91             Free support can be requested via regular CPAN bug-tracking system. There is
92             no guaranteed reaction time or solution time. It depends on business load.
93             That doesn't mean that ticket via rt aren't handles as soon as possible,
94             that means that soon depends on how much I have to do.
95              
96             Business and commercial support should be aquired via preferred freelancer
97             agencies.
98              
99             =head1 AUTHOR
100              
101             Jens Rehsack
102             CPAN ID: REHSACK
103             rehsack@cpan.org
104             http://search.cpan.org/~rehsack/
105              
106             =head1 COPYRIGHT
107              
108             This program is free software; you can redistribute
109             it and/or modify it under the same terms as Perl itself.
110              
111             The full text of the license can be found in the
112             LICENSE file included with this module.
113              
114              
115             =head1 SEE ALSO
116              
117             perl(1), L
118              
119             =cut
120              
121             1;
122