File Coverage

lib/Decl/Semantics/Template.pm
Criterion Covered Total %
statement 10 18 55.5
branch 0 2 0.0
condition n/a
subroutine 4 8 50.0
pod 5 5 100.0
total 19 33 57.5


line stmt bran cond sub pod time code
1             package Decl::Semantics::Template;
2            
3 12     12   80 use warnings;
  12         22  
  12         464  
4 12     12   70 use strict;
  12         26  
  12         533  
5            
6 12     12   66 use base qw(Decl::Node);
  12         22  
  12         3656  
7            
8             =head1 NAME
9            
10             Decl::Semantics::Template - implements a template
11            
12             =head1 VERSION
13            
14             Version 0.02
15            
16             =cut
17            
18             our $VERSION = '0.01';
19            
20            
21             =head1 SYNOPSIS
22            
23             Templates...
24            
25             =head2 defines(), tags_defined()
26            
27             Called by Decl::Semantics during import, to find out what tags this plugin claims to implement.
28            
29             =cut
30            
31 0     0 1 0 sub defines { ('template'); }
32 12     12 1 85 sub tags_defined { Decl->new_data(<
33             template
34             EOF
35            
36             =head2 parse_body
37            
38             The template has ambiguous callability. Parse_body probably isn't where to indicate it, though.
39            
40             =cut
41            
42             sub parse_body {
43 0     0 1   my ($self) = @_;
44 0           $self->{callable} = '?';
45             }
46            
47             =head2 go
48            
49             When called, Template writes to itself. By default, that propagates up the tree until an output handler is found.
50            
51             =cut
52            
53             sub go {
54 0     0 1   my ($self) = @_;
55 0           $self->write($self->express);
56             }
57            
58             =head2 express
59            
60             The C function is where the template is sent to a template engine. If a node is supplied for context, it's
61             used as the value source; otherwise, the template itself is taken as the value source. A hashref can also be passed
62             into the express call as a value source, or an arrayref of different sources to be queried one after the other.
63            
64             =cut
65            
66             sub express {
67 0     0 1   my ($self, $values) = @_;
68            
69 0 0         $values = $self unless $values;
70 0           $Decl::template_engine->express($self->body, $values);
71             }
72            
73             =head1 AUTHOR
74            
75             Michael Roberts, C<< >>
76            
77             =head1 BUGS
78            
79             Please report any bugs or feature requests to C, or through
80             the web interface at L. I will be notified, and then you'll
81             automatically be notified of progress on your bug as I make changes.
82            
83             =head1 LICENSE AND COPYRIGHT
84            
85             Copyright 2010 Michael Roberts.
86            
87             This program is free software; you can redistribute it and/or modify it
88             under the terms of either: the GNU General Public License as published
89             by the Free Software Foundation; or the Artistic License.
90            
91             See http://dev.perl.org/licenses/ for more information.
92            
93             =cut
94            
95             1; # End of Decl::Semantics::Template