blib/lib/Template/Plugin/Stash.pm

filter: Statementstmt 52.3% 11 / 21 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.0% 3 / 5 Podpod 50.0% 1 / 2 totaltotal 50.0% 15 / 30 CC 4 SCAR 23.6
CC
4
Cov
48%
stash
20.0
new
2.0
BEGIN
1.0
CRAP 10.6
↑ Summary
1 =head1 NAME
2  
3 Template::Plugin::Stash - expose the stash, ideal for I<Dumper>ing...
4  
5 =head1 SYNOPSIS
6  
7 [% USE Stash %]
8 [% USE Dumper Indent = 1%]
9 <pre>[% Dumper.dump_html( Stash.stash() ) %]</pre>
10  
11 =head1 DESCRIPTION
12  
13 Instead of messing with C<< [% PERL %] >> blocks
14 to get at the stash, simply C<< [% USE Stash %] >>.
15  
16 Output will look something like
17  
18 $VAR1 = {
19 'global' => {},
20 'var1' => 6666666,
21 'var2' => {
22 'e' => 'f',
23 'g' => 'h',
24 'a' => 'b',
25 'c' => 'd'
26 },
27 };
28  
29 which should be all you need.
30  
31 =head1 SEE ALSO
32  
33 L<Template::Plugin|Template::Plugin>,
34 L<Template::Plugin::Dumper|Template::Plugin::Dumper>.
35  
36 =head1 BUGS/SUGGESTIONS/ETC
37
38 To report bugs/suggestions/etc, go to
39 E<lt>http://rt.cpan.org/NoAuth/Bugs.html?Dist=Template-Plugin-StashE<gt>
40 or send mail to E<lt>bug-Template-Plugin-Stash#rt.cpan.orgE<gt>.
41  
42 =head1 LICENSE
43
44 Copyright (c) 2003-2004 by D.H. (PodMaster). All rights reserved.
45
46 This module is free software; you can redistribute it and/or modify it
47 under the same terms as Perl itself. The LICENSE file contains the full
48 text of the license.
49  
50 =cut
51  
52 package Template::Plugin::Stash;
53 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
54 1 ▶use base qw[ Template::Plugin ];
Subroutine BEGIN: called CC=1 SCAR=0.0
55 1 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
56 1 $VERSION = sprintf "%d.%03d", q$Revision: 1.6 $ =~ /(\d+).(\d+)/g;
57
58  
59 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
60 0 my( $class, $con ) = @_;
61 0 return bless { _CONTEXT => $con }, $class;
62 }
63
64 0 ▶sub stash {
Subroutine stash: not called CC=4 SCAR=30.0
Pod undocumented
65 0 my $self = shift;
66 0 my $stash = { %{ $self->{_CONTEXT}->stash() } }; # do clone as Template::Stash does it
67  
68 delete $stash->{$_}
69 0 for
70 qw[ template dec inc component Stash ],
71 0 grep { /^_/ } keys %$stash;
72
73 0 for my $k( keys %$stash ){
74 0 ▶ delete $stash->{$k} if ref($stash->{$k}) =~ /^\QTemplate::Plugin/;
Branch: 1 branch
BranchTrueFalseTotal
if ref($stash->{$k}) =~ /^Template\:\:Plugin/ 0 0 0
75 }
76  
77 0 return $stash;
78 }
79  
80 1 1;
↑ Summary