-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTemplate.pm
71 lines (50 loc) · 1.49 KB
/
Template.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package MobaSiF::Template;
use 5.008;
use strict;
use warnings;
use File::stat;
use MobaSiF::Template::Compiler;
require Exporter;
our @ISA = qw(Exporter);
our %EXPORT_TAGS = ( 'all' => [ qw() ] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
our $VERSION = '0.02';
require XSLoader;
XSLoader::load('MobaSiF::Template', $VERSION);
our $DEVELOP = 0;
sub render {
my ($template, $compiled_template, $param, $param2, $param3) = @_;
if ($DEVELOP) {
my $template_stat = stat($template);
my $compiled_stat = stat($compiled_template);
if ($template_stat->mtime > $compiled_stat->mtime) {
MobaSiF::Template::Compiler::compile($template, $compiled_template);
}
}
return MobaSiF::Template::insert($compiled_template, $param, $param2, $param3);
}
1;
__END__
=encoding euc-jp
=head1 NAME
MobaSiF::Template - Very fast Template module written by XS.
=head1 SYNOPSIS
use MobaSiF::Template;
my $compiled_template_file = "compiled_template.bin";
my $refParamHash = {
base => 'MobaSiF::Template Test',
list => [
{ id => 1 , value => 'A' },
{ id => 2 , value => 'B' },
]
};
$html = MobaSiF::Template::insert($compiled_template_file, $refParamHash);
print $html;
=head1 ABSTRACT
事前コンパイルされたテンプレートバイナリを用いて高速なテンプレート処理を行います。
ループ・条件分岐・置換(URL ENCODE, HTMLSPECIALCHARS(+NL2BR) が可能)に対応しており、基本的なHTMLテンプレートの処理に対応できます。
=head1 DESCRIPTION
=head1 SEE ALSO
MobaSiF::Template::Compiler
=cut