| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Eidolon::Driver::Template::Toolkit; |
|
2
|
|
|
|
|
|
|
# ============================================================================== |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# Eidolon |
|
5
|
|
|
|
|
|
|
# Copyright (c) 2009, Atma 7 |
|
6
|
|
|
|
|
|
|
# --- |
|
7
|
|
|
|
|
|
|
# Eidolon/Driver/Template/Toolkit.pm - Template Toolkit driver |
|
8
|
|
|
|
|
|
|
# |
|
9
|
|
|
|
|
|
|
# ============================================================================== |
|
10
|
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
41940
|
use base qw/Eidolon::Driver::Template/; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
77
|
|
|
12
|
1
|
|
|
1
|
|
22203
|
use Template; |
|
|
1
|
|
|
|
|
72212
|
|
|
|
1
|
|
|
|
|
38
|
|
|
13
|
1
|
|
|
1
|
|
14
|
use warnings; |
|
|
1
|
|
|
|
|
8
|
|
|
|
1
|
|
|
|
|
31
|
|
|
14
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
282
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = "0.01"; # 2009-05-22 02:33:02 |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
|
19
|
|
|
|
|
|
|
# \% new($templates_dir, $additional) |
|
20
|
|
|
|
|
|
|
# constructor |
|
21
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
|
22
|
|
|
|
|
|
|
sub new |
|
23
|
|
|
|
|
|
|
{ |
|
24
|
0
|
|
|
0
|
1
|
|
my ($class, $templates_dir, $additional, $self); |
|
25
|
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
($class, $templates_dir, $additional) = @_; |
|
27
|
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
$self = $class->SUPER::new($templates_dir); |
|
29
|
0
|
|
0
|
|
|
|
$self->{"additional"} = $additional || {}; |
|
30
|
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
return $self; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
|
35
|
|
|
|
|
|
|
# parse($tpl) |
|
36
|
|
|
|
|
|
|
# parse template |
|
37
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
|
38
|
|
|
|
|
|
|
sub parse |
|
39
|
|
|
|
|
|
|
{ |
|
40
|
0
|
|
|
0
|
1
|
|
my ($self, $tpl) = @_; |
|
41
|
|
|
|
|
|
|
|
|
42
|
0
|
0
|
|
|
|
|
throw DriverError::Template::Open($tpl) if (!-f $self->{"templates_dir"}.$tpl); |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# create object |
|
45
|
0
|
|
|
|
|
|
$self->{"object"} = Template->new |
|
46
|
|
|
|
|
|
|
( |
|
47
|
|
|
|
|
|
|
"INCLUDE_PATH" => $self->{"templates_dir"}, |
|
48
|
0
|
|
|
|
|
|
%{ $self->{"additional"} } |
|
49
|
|
|
|
|
|
|
); |
|
50
|
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
$self->{"object"}->process($tpl, $self->{"vars"}, \$self->{"result"}); |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
|
55
|
|
|
|
|
|
|
# render() |
|
56
|
|
|
|
|
|
|
# render template |
|
57
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
|
58
|
|
|
|
|
|
|
sub render |
|
59
|
|
|
|
|
|
|
{ |
|
60
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
61
|
|
|
|
|
|
|
|
|
62
|
0
|
0
|
|
|
|
|
throw DriverError::Template::NotParsed if (!$self->{"object"}); |
|
63
|
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
print $self->{"result"}; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
__END__ |