TAL/Output.pm untested

filter: Statementstmt 0.0% 0 / 15 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 29 CC 2 SCAR 11.5
CC
2
Cov
0%
charset
6.0
new
2.0
render
2.0
CRAP 3.1
1 =head1 NAME
2  
3 Template::TAL::Output - base class for Template::TAL output layers
4  
5 =head1 SYNOPSIS
6  
7 my $tt = Template::TAL->new( output => "Template::TAL::Output::XML" );
8 print $tt->process('foo');
9  
10 =head1 DESCRIPTION
11  
12 The render method of Template::TAL::Template produces a DOM tree. TT then
13 gives that tree to its output class (in $tt->output) for conversion to
14 a byte sequence. This class is the superclass of all Template::TAL output
15 classes. By default, TT will use Template::TAL::Output::HTML, but you
16 may want to use Template::TAL::Output::XML to produce XML output.
17  
18 =head1 SUBCLASSING
19  
20 You only have to override the 'render' method, which should take an
21 XML::LibXML::Document object, and return a byte sequence. Preferably,
22 you should respect the 'charset' property of the instance (assuming
23 that applies to your output method).
24  
25 =cut
26  
27 package Template::TAL::Output;
28 use warnings;
29 use strict;
30 use Carp qw( croak );
31  
32 =head1 METHODS
33  
34 =over
35  
36 =item new()
37  
38 Create a new instance of the output class.
39  
40 =cut
41  
42 sub new {
43 return bless {}, shift;
44 }
45  
46 =item charset
47  
48 Get/set chained accessor that returns/sets the character set that the output
49 will be encoded into. By default, this is 'utf-8'.
50  
51 =cut
52  
53 sub charset {
54 my $self = shift;
55 return $self->{charset} ||= "utf-8" unless @_;
56 $self->{charset} = shift;
57 return $self;
58 }
59  
60 =item render( XML DOM )
61  
62 returns a byte sequence representing the XML DOM passed.
63  
64 =cut
65  
66 sub render {
67 croak("Template::TAL::Output is abstract - use a subclass");
68 }
69  
70 =back
71  
72 =head1 COPYRIGHT
73  
74 Written by Tom Insam, Copyright 2005 Fotango Ltd. All Rights Reserved.
75  
76 This program is free software; you can redistribute
77 it and/or modify it under the same terms as Perl itself.
78  
79 =head1 BUGS
80  
81 None known. Please see L<Template::TAL> for details of how to report bugs
82  
83 =head1 SEE ALSO
84  
85 L<Template::TAL>
86  
87 =cut
88  
89 1;