line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# StandaloneTagNode --
|
2
|
|
|
|
|
|
|
# tag_type (scalar): type of tag
|
3
|
|
|
|
|
|
|
# pairs (hash): attribute-value pairs
|
4
|
|
|
|
|
|
|
package Text::PORE::Node::Standalone;
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use Text::PORE::Node::Attr;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
25
|
|
7
|
1
|
|
|
1
|
|
610
|
use Text::PORE::Group;
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
29
|
|
8
|
1
|
|
|
1
|
|
8
|
use strict;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
827
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
@Text::PORE::Node::Standalone::ISA = qw(Text::PORE::Node::Attr);
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my %StandaloneFunctions = (
|
13
|
|
|
|
|
|
|
'render' => 'RenderTagFunc',
|
14
|
|
|
|
|
|
|
'ref' => 'RefTagFunc',
|
15
|
|
|
|
|
|
|
'table' => 'TableTagFunc',
|
16
|
|
|
|
|
|
|
);
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub new {
|
19
|
16
|
|
|
16
|
0
|
28
|
my $type = shift;
|
20
|
16
|
|
|
|
|
25
|
my $lineno = shift;
|
21
|
16
|
|
|
|
|
27
|
my $tag_type = shift;
|
22
|
16
|
|
|
|
|
33
|
my $pairs = shift;
|
23
|
|
|
|
|
|
|
|
24
|
16
|
|
33
|
|
|
122
|
my $self = bless {}, ref($type) || $type;
|
25
|
|
|
|
|
|
|
|
26
|
16
|
|
|
|
|
135
|
$self = $self->SUPER::new($lineno, $tag_type, $pairs);
|
27
|
|
|
|
|
|
|
|
28
|
16
|
|
33
|
|
|
106
|
bless $self, ref($type) || $type;
|
29
|
|
|
|
|
|
|
}
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub traverse {
|
32
|
28
|
|
|
28
|
0
|
31
|
my $self = shift;
|
33
|
28
|
|
|
|
|
31
|
my $globals = shift;
|
34
|
|
|
|
|
|
|
|
35
|
28
|
50
|
|
|
|
71
|
$self->output("[$self->{'tag_type'}:$self->{'lineno'}]")
|
36
|
|
|
|
|
|
|
if $self->getDebug();
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# lookup method
|
39
|
28
|
|
|
|
|
64
|
my ($method) = $StandaloneFunctions{$self->{'tag_type'}};
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# execute that method
|
42
|
28
|
50
|
|
|
|
54
|
if ($method) {
|
43
|
28
|
|
|
|
|
72
|
$self->error($self->$method($globals));
|
44
|
|
|
|
|
|
|
} else {
|
45
|
0
|
|
|
|
|
0
|
$self->error("Unsupported tag [$self->{'tag_type'}]");
|
46
|
|
|
|
|
|
|
}
|
47
|
|
|
|
|
|
|
|
48
|
28
|
|
|
|
|
246
|
return $self->errorDump();
|
49
|
|
|
|
|
|
|
}
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# RenderTagFunc: renders the attribute of the current object. Currently
|
52
|
|
|
|
|
|
|
# only prints that attribute out
|
53
|
|
|
|
|
|
|
sub RenderTagFunc {
|
54
|
28
|
|
|
28
|
0
|
35
|
my $self = shift;
|
55
|
28
|
|
|
|
|
36
|
my $globals = shift;
|
56
|
|
|
|
|
|
|
|
57
|
28
|
|
|
|
|
104
|
my ($attr) = $self->retrieveSlot($globals, $self->{'attrs'}{'attr'});
|
58
|
28
|
|
|
|
|
167
|
my ($tpl) = $self->retrieveSlot($globals, $self->{'attrs'}{'tpl'});
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
28
|
50
|
|
|
|
101
|
if (ref($attr) =~ /ARRAY/) {
|
|
|
50
|
|
|
|
|
|
62
|
0
|
|
|
|
|
0
|
$self->error("Cannot render array attribute '$self->{attrs}{attr}'");
|
63
|
|
|
|
|
|
|
} elsif (ref($attr)) {
|
64
|
0
|
|
|
|
|
0
|
$self->output($attr->ToHtml());
|
65
|
|
|
|
|
|
|
# TODO - Render according to default template
|
66
|
|
|
|
|
|
|
} else {
|
67
|
28
|
|
|
|
|
75
|
$self->output($attr);
|
68
|
|
|
|
|
|
|
}
|
69
|
|
|
|
|
|
|
|
70
|
28
|
|
|
|
|
186
|
return $self->errorDump();
|
71
|
|
|
|
|
|
|
}
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# RefTagFunc: returns a URL reference to the attribute of the current object.
|
74
|
|
|
|
|
|
|
# Returns an error if the attribute is not itself an object
|
75
|
|
|
|
|
|
|
sub RefTagFunc {
|
76
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
77
|
0
|
|
|
|
|
|
my $globals = shift;
|
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
my (%attr) = %{$self->{'attrs'}};
|
|
0
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
my ($attr_name) = $attr{'attr'};
|
82
|
0
|
|
|
|
|
|
my ($attr) = $self->retrieveSlot($globals, $attr_name);
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# TODO - improve error test
|
85
|
0
|
0
|
|
|
|
|
if (! $attr) {
|
|
|
0
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
$self->error("Current object has no '$attr_name' attribute");
|
87
|
|
|
|
|
|
|
}
|
88
|
|
|
|
|
|
|
elsif (! ref($attr)) {
|
89
|
0
|
|
|
|
|
|
$self->error("The attribute '$attr_name' of current " .
|
90
|
|
|
|
|
|
|
"object is not an object.");
|
91
|
|
|
|
|
|
|
}
|
92
|
|
|
|
|
|
|
else {
|
93
|
0
|
|
|
|
|
|
$self->output($attr->ToLink());
|
94
|
|
|
|
|
|
|
}
|
95
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
return $self->errorDump();
|
97
|
|
|
|
|
|
|
}
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# TableTagFunc: Formats contents of a list into a table.
|
100
|
|
|
|
|
|
|
# tag:
|
101
|
|
|
|
|
|
|
# width=... cellspacing=... cellpadding=... align=..
|
102
|
|
|
|
|
|
|
# valign=...>
|
103
|
|
|
|
|
|
|
sub TableTagFunc {
|
104
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
105
|
0
|
|
|
|
|
|
my $globals = shift;
|
106
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
|
my %attr = %{$self->{'attrs'}};
|
|
0
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
my ($attr_name) = $attr{'attr'};
|
110
|
0
|
|
|
|
|
|
my ($objects) = $self->retrieveSlot($globals, $attr_name);
|
111
|
|
|
|
|
|
|
# TODO - probably should test isa()
|
112
|
0
|
0
|
|
|
|
|
return unless $objects;
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# TODO - combine with previous statement
|
115
|
0
|
0
|
0
|
|
|
|
if ($objects && ref($objects) !~ /ARRAY/) {
|
116
|
0
|
|
|
|
|
|
$self->error("The attribute '$attr_name' of current object is not a list.");
|
117
|
0
|
|
|
|
|
|
return $self->errorDump();
|
118
|
|
|
|
|
|
|
}
|
119
|
|
|
|
|
|
|
|
120
|
0
|
|
|
|
|
|
my ($strings);
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
my ($object);
|
123
|
0
|
|
|
|
|
|
foreach $object (@$objects) {
|
124
|
0
|
0
|
|
|
|
|
my $string = ref($object) ? $object->ToHtml() : $object;
|
125
|
0
|
|
|
|
|
|
push @$strings, $string;
|
126
|
|
|
|
|
|
|
}
|
127
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
delete $attr{'attr'};
|
129
|
0
|
|
|
|
|
|
$attr{'table_items'} = $strings;
|
130
|
0
|
|
|
|
|
|
my $table = new Table(%attr);
|
131
|
0
|
|
|
|
|
|
$self->output($table->ToHtml);
|
132
|
|
|
|
|
|
|
|
133
|
0
|
|
|
|
|
|
return $self->errorDump();
|
134
|
|
|
|
|
|
|
}
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
1;
|