line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tree::Template::Declare::HTML_Element; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$Tree::Template::Declare::HTML_Element::DIST = 'Tree-Template-Declare'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
$Tree::Template::Declare::HTML_Element::VERSION = '0.7'; |
6
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
26
|
|
7
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
20
|
|
8
|
1
|
|
|
1
|
|
2
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
41
|
|
9
|
1
|
|
|
1
|
|
3
|
use HTML::Element; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
10
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
1
|
|
|
1
|
0
|
1
|
my ($class)=@_; |
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
|
|
4
|
return bless {},$class; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _munge_exports { |
18
|
1
|
|
|
1
|
|
1
|
my ($self,$exports)=@_; |
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
|
|
5
|
my %all_exports=( |
21
|
|
|
|
|
|
|
%{$exports}, |
22
|
|
|
|
|
|
|
text_node => sub($) { |
23
|
|
|
|
|
|
|
$exports->{node}->( |
24
|
|
|
|
|
|
|
sub { |
25
|
2
|
|
|
2
|
|
35
|
$exports->{name}->('~text'); |
26
|
2
|
|
|
|
|
8
|
$exports->{attribs}->(text => $_[0]); |
27
|
2
|
|
|
2
|
|
12
|
}); |
28
|
|
|
|
|
|
|
}, |
29
|
1
|
|
|
|
|
1
|
); |
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
4
|
return \%all_exports; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub new_tree { |
35
|
1
|
|
|
1
|
0
|
2
|
my ($self)=@_; |
36
|
|
|
|
|
|
|
|
37
|
1
|
|
|
|
|
9
|
return bless [],'Tree::Template::Declare::HTML_Element::Tree'; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub finalize_tree { |
41
|
1
|
|
|
1
|
0
|
2
|
my ($self,$tree)=@_; |
42
|
|
|
|
|
|
|
|
43
|
1
|
|
|
|
|
2
|
my $dom=$tree->[0]; |
44
|
1
|
|
|
|
|
4
|
$dom->deobjectify_text(); |
45
|
1
|
|
|
|
|
43
|
return $dom; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub new_node { |
49
|
7
|
|
|
7
|
0
|
7
|
my ($self)=@_; |
50
|
|
|
|
|
|
|
|
51
|
7
|
|
|
|
|
17
|
return HTML::Element->new('~comment'); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub add_child_node { |
55
|
7
|
|
|
7
|
0
|
7
|
my ($self,$parent,$child)=@_; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
7
|
100
|
|
|
|
32
|
if ($parent->isa('Tree::Template::Declare::HTML_Element::Tree')) { |
59
|
1
|
|
|
|
|
1
|
push @{$parent},$child; |
|
1
|
|
|
|
|
1
|
|
60
|
1
|
|
|
|
|
3
|
return $parent; |
61
|
|
|
|
|
|
|
} |
62
|
6
|
|
|
|
|
11
|
return $parent->push_content($child); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub set_node_name { |
66
|
7
|
|
|
7
|
0
|
7
|
my ($self,$node,$name)=@_; |
67
|
|
|
|
|
|
|
|
68
|
7
|
|
|
|
|
13
|
return $node->tag($name); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub set_node_attributes { |
72
|
4
|
|
|
4
|
0
|
2
|
my ($self,$node,$attrs)=@_; |
73
|
|
|
|
|
|
|
|
74
|
4
|
|
|
|
|
5
|
while (my ($name,$val)=each %{$attrs}) { |
|
8
|
|
|
|
|
45
|
|
75
|
4
|
|
|
|
|
7
|
$node->attr($name, $val); |
76
|
|
|
|
|
|
|
} |
77
|
4
|
|
|
|
|
6
|
return; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=pod |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=encoding UTF-8 |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 NAME |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Tree::Template::Declare::HTML_Element - adaptor for HTML::Element |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 VERSION |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
version 0.7 |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 SYNOPSIS |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
See L. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 SPECIFICITIES |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
This module will build trees using L. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
To create text nodes, you would be forced to say: |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
node { |
105
|
|
|
|
|
|
|
name '~text'; |
106
|
|
|
|
|
|
|
attribs text => 'some text'; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
which is too cumbersone. You can instead use: |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
text_node 'some text'; |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
HTML::Element's C method will be called by |
114
|
|
|
|
|
|
|
C before returning the tree object. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=for Pod::Coverage add_child_node finalize_tree new new_node new_tree set_node_attributes set_node_name |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 AUTHOR |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Gianni Ceccarelli |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
This software is copyright (c) 2015 by Gianni Ceccarelli . |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
127
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=cut |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
__END__ |