line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Orze::Drivers::Template; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
4337
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
8257
|
use Template; |
|
1
|
|
|
|
|
57613
|
|
|
1
|
|
|
|
|
34
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
11
|
use base "Orze::Drivers"; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
686
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Orze::Drivers::Template - Create a page using the Template module |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 DESCRIPTION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
This driver uses the famous Template module to create pages. It process |
17
|
|
|
|
|
|
|
the given template using all the variables of the page as its own |
18
|
|
|
|
|
|
|
variables. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
It takes care of the following attributes: |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=over |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=item template |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
The template that will be used. Notice that the default value is "index". |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=back |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
All the templates must be put in the C directory. |
31
|
|
|
|
|
|
|
The C directory will be used for all the includes |
32
|
|
|
|
|
|
|
defined in the template file. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
The new file will be put in C according the current |
35
|
|
|
|
|
|
|
page path and name. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 EXAMPLE |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Homepage |
41
|
|
|
|
|
|
|
Hello world |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 SEE ALSO |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Lookt at L for the template language. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 METHODS |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head2 process |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Do the real processing |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub process { |
57
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
my $page = $self->{page}; |
60
|
0
|
|
|
|
|
|
my $variables = $self->{variables}; |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
my $template = $page->att('template'); |
63
|
0
|
|
|
|
|
|
my $extension = $page->att('extension'); |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
$variables->{root} = $self->root(); |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
my $name = $page->att('name'); |
68
|
0
|
|
|
|
|
|
$variables->{page} = $name; |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
my $output = $self->output($name . "." . $extension); |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
my $tt = Template->new( |
73
|
|
|
|
|
|
|
RELATIVE => 1, |
74
|
|
|
|
|
|
|
INCLUDE_PATH => [ |
75
|
|
|
|
|
|
|
"includes/Template", |
76
|
|
|
|
|
|
|
"templates/Template", |
77
|
|
|
|
|
|
|
], |
78
|
|
|
|
|
|
|
); |
79
|
|
|
|
|
|
|
|
80
|
0
|
0
|
|
|
|
|
$tt->process($template . "." . $extension, |
81
|
|
|
|
|
|
|
$variables, |
82
|
|
|
|
|
|
|
$output, |
83
|
|
|
|
|
|
|
) |
84
|
|
|
|
|
|
|
|| $self->warning("processing error, ", $tt->error()); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |