line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=head1 NAME |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
OpenFrame::WebApp::Template::TT2 - a TT2 template processing wrapper |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 SYNOPSIS |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use OpenFrame::WebApp::Template::TT2; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my $tmpl = new OpenFrame::WebApp::Template::TT2; |
10
|
|
|
|
|
|
|
$tmpl->file( $local_file_path ) |
11
|
|
|
|
|
|
|
->template_vars( { fred => fish } ); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
$response = $tmpl->process; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=cut |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
package OpenFrame::WebApp::Template::TT2; |
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
66525
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
20
|
1
|
|
|
1
|
|
4
|
use warnings::register; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
125
|
|
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
5
|
use Error qw( :try ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
23
|
1
|
|
|
1
|
|
99
|
use Template; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
24
|
1
|
|
|
1
|
|
478
|
use OpenFrame::WebApp::Template::Error; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
54
|
|
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
1
|
|
5
|
use base qw( OpenFrame::WebApp::Template ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
512
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
our $VERSION = (split(/ /, '$Revision: 1.10 $'))[1]; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
our $TT2 = new Template; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
## set/get the TT2 processor |
33
|
|
|
|
|
|
|
sub tt2 { |
34
|
|
|
|
|
|
|
my $self = shift; |
35
|
|
|
|
|
|
|
if (@_) { |
36
|
|
|
|
|
|
|
$TT2 = shift; |
37
|
|
|
|
|
|
|
return $self; |
38
|
|
|
|
|
|
|
} else { |
39
|
|
|
|
|
|
|
return $TT2; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
## use tt2 as default |
44
|
|
|
|
|
|
|
sub default_processor { |
45
|
|
|
|
|
|
|
my $self = shift; |
46
|
|
|
|
|
|
|
return $self->tt2; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
## process the template file |
50
|
|
|
|
|
|
|
sub process_template { |
51
|
|
|
|
|
|
|
my $self = shift; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my $output; |
54
|
|
|
|
|
|
|
$self->processor->process( $self->file, $self->template_vars, \$output ); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
unless ($output) { |
57
|
|
|
|
|
|
|
throw OpenFrame::WebApp::Template::Error( |
58
|
|
|
|
|
|
|
flag => eTemplateError, |
59
|
|
|
|
|
|
|
template => $self->file, |
60
|
|
|
|
|
|
|
message => $self->processor->error->as_string, |
61
|
|
|
|
|
|
|
); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
return $output; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
__END__ |