line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Template::Direct::SubPage; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
11
|
use base Template::Direct::Page; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
200
|
|
4
|
2
|
|
|
2
|
|
14
|
use Template::Direct; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
48
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
81
|
|
7
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
69
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Template::Direct::SubPage - Handle a sub page load |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Provide support for loading other templates from the current template. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 METHODS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
2
|
|
11
|
use Carp; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
910
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head2 I<$class>->new( $index, $line ) |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Create a new instance object. |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=cut |
28
|
|
|
|
|
|
|
sub new { |
29
|
1
|
|
|
1
|
1
|
7
|
my ($class, $index, $location, %p) = @_; |
30
|
1
|
|
|
|
|
13
|
my $self = $class->SUPER::new(undef, %p); |
31
|
1
|
|
|
|
|
4
|
$self->{'startTag'} = $index; |
32
|
1
|
|
|
|
|
3
|
$self->{'Location'} = $location; |
33
|
1
|
|
|
|
|
4
|
return $self; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 $object->compile( ) |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Modifies a template with the data listed correctly. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
sub compile { |
42
|
1
|
|
|
1
|
1
|
4
|
my ($self, $data, $template, %p) = @_; |
43
|
1
|
50
|
|
|
|
5
|
return if ref($template) ne 'SCALAR'; |
44
|
1
|
|
|
|
|
5
|
my $section = $self->getContents( $data ); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# Mark the section as being processed |
47
|
1
|
|
|
|
|
13
|
$self->getLocation( $template, $self->{'startTag'} ); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# Set the section in the Location |
50
|
1
|
|
|
|
|
9
|
$self->setSection($template, $section); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 I<$page>->getContents( $data ) |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Returns the compiled template by loading the file |
56
|
|
|
|
|
|
|
and passing the right scoped data to it. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
sub getContents { |
60
|
1
|
|
|
1
|
1
|
3
|
my ($self, $data) = @_; |
61
|
1
|
50
|
|
|
|
5
|
if(not $self->{'content'}) { |
62
|
1
|
|
|
|
|
4
|
$self->{'content'} = $self->loadTemplate(); |
63
|
1
|
|
|
|
|
5
|
chomp($self->{'content'}); |
64
|
|
|
|
|
|
|
} |
65
|
1
|
|
|
|
|
15
|
return $self->SUPER::compile( $data ); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 I<$page>->loadTemplate( ) |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Load a Template object with the location of the sub page. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
73
|
|
|
|
|
|
|
sub loadTemplate { |
74
|
1
|
|
|
1
|
1
|
2
|
my ($self) = @_; |
75
|
1
|
|
|
|
|
12
|
my $newdoc = Template::Direct->new( |
76
|
|
|
|
|
|
|
Directory => $self->{'Directory'}, |
77
|
|
|
|
|
|
|
Location => $self->{'Location'}, |
78
|
|
|
|
|
|
|
); |
79
|
1
|
|
|
|
|
8
|
return $newdoc->load( Language => $self->{'Language'} ); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 AUTHOR |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Martin Owens - Copyright 2007, AGPL |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |
87
|
|
|
|
|
|
|
1; |