File Coverage

blib/lib/Template/Plugin/Clone.pm
Criterion Covered Total %
statement 18 18 100.0
branch 2 2 100.0
condition n/a
subroutine 6 6 100.0
pod 0 1 0.0
total 26 27 96.3


line stmt bran cond sub pod time code
1             package Template::Plugin::Clone;
2 2     2   64869 use Template::Plugin::Procedural;
  2         2458  
  2         64  
3 2     2   12 use base qw(Template::Plugin::Procedural);
  2         4  
  2         166  
4              
5 2     2   2781 use Storable qw(dclone);
  2         6971  
  2         149  
6              
7 2     2   14 use strict;
  2         5  
  2         64  
8             #use warnings;
9              
10 2     2   10 use vars qw($VERSION);
  2         4  
  2         227  
11             $VERSION = "0.01";
12              
13             sub clone
14             {
15 6 100   6 0 111316 return dclone($_[0])
16             if ref $_[0];
17              
18 2         5 my $thingy = shift;
19 2         19 return $thingy;
20             }
21              
22             1;
23              
24             =head1 NAME
25              
26             Template::Plugin::Clone - clone objects within TT
27              
28             =head1 SYNOPSIS
29              
30             [% USE Clone %]
31             [% bar = Clone.clone(foo) %]
32              
33             [% USE CloneVMethods %]
34             [% baz = foo.clone %]
35              
36             =head1 DESCRIPTION
37              
38             Clones objects and datastructures from within the Template
39             Toolkit using the C method from B. If the item
40             passed to the function isn't a object or data structure then it
41             is simply copied.
42              
43             To access the C function like a class method, simply use the
44             plugin from within a Template Toolkit template:
45              
46             [% USE Clone %]
47              
48             And then call the method against the Clone object.
49              
50             [% bar = Clone.close(foo) %]
51              
52             Alternatively you can load the function as vmethods:
53              
54             [% USE CloneVMethods %]
55             [% baz foo.clone %]
56              
57             Using the VMethods plugin as above will cause the vmethods to be in
58             effect for the current template and all templates called from that
59             template. To allow all templates called from any instance of the
60             Template module load the module from Perl with the 'install'
61             parameter.
62              
63             use Template::Plugin::CloneVMethods 'install';
64              
65             =head1 AUTHOR
66              
67             Written by Mark Fowler Emark@twoshortplanks.comE
68              
69             Copryright Mark Fowler 2003. All Rights Reserved.
70              
71             This program is free software; you can redistribute it
72             and/or modify it under the same terms as Perl itself.
73              
74             Main functionality imported from Storable, which was written by
75             Raphael Manfredi ERaphael_Manfredi@pobox.comE and is now
76             maintained by the perl5-porters Eperl5-porters@perl.orgE
77              
78             =head1 BUGS
79              
80             None known.
81              
82             Bugs should be reported to me via the CPAN RT system.
83             L.
84              
85             =head1 SEE ALSO
86              
87             L
88             L
89             L
90              
91             =cut
92              
93             1;