Added more tests for conditionals. Need to fix linking in POD. - Intermediate commit!
[p5sagit/Excel-Template.git] / lib / Excel / Template / Container / KeepLeadingZeros.pm
1 package Excel::Template::Container::KeepLeadingZeros;
2
3 use strict;
4
5 BEGIN {
6     use vars qw(@ISA);
7     @ISA = qw(Excel::Template::Container);
8
9     use Excel::Template::Container;
10 }
11
12 sub render
13 {
14     my $self = shift;
15     my ($context) = @_;
16
17     my $worksheet = $context->active_worksheet;
18
19     $worksheet
20         ? $worksheet->keep_leading_zeros( 1 )
21         : $context->mark( keep_leading_zeros => 1 );
22
23     my $rv = $self->SUPER::render($context);
24
25     $worksheet
26         ? $worksheet->keep_leading_zeros( 0 )
27         : $context->mark( keep_leading_zeros => 0 );
28
29     return $rv;
30 }
31
32 1;
33 __END__
34
35 =head1 NAME
36
37 Excel::Template::Container::KeepLeadingZeros - Excel::Template::Container::KeepLeadingZeros
38
39 =head1 PURPOSE
40
41 To set the keep_leading_zeros flag for the surrounding worksheet or any worksheets that might be contained within this node.
42
43 =head1 NODE NAME
44
45 KEEP_LEADING_ZEROS
46
47 =head1 INHERITANCE
48
49 L<CONTAINER|Excel::Template::Container>
50
51 =head1 ATTRIBUTES
52
53 None
54
55 =head1 CHILDREN
56
57 None
58
59 =head1 EFFECTS
60
61 Alters how leading zeros are interpreted by L<Spreadsheet::WriteExcel>.
62
63 =head1 DEPENDENCIES
64
65 None
66
67 =head1 USAGE
68
69   <worksheet>
70     ... Cells here will NOT have leading-zeros preserved
71     <keep_leading_zeros>
72       ... Cells here will have leading-zeros preserved
73     </keep_leading_zeros>
74     ... Cells here will NOT have leading-zeros preserved
75   </worksheet>
76
77   <keep_leading_zeros>
78     <worksheet>
79       ... Cells here will have leading-zeros preserved
80     </worksheet>
81     <worksheet>
82       ... Cells here will have leading-zeros preserved
83     </worksheet>
84   </keep_leading_zeros>
85
86 =head1 AUTHOR
87
88 Rob Kinyon (rob.kinyon@gmail.com)
89
90 =head1 SEE ALSO
91
92 L<CELL|Excel::Template::Element::Cell>, L<Spreadsheet::WriteExcel>
93
94 =cut