Leser: 2
|< 1 2 >| | 15 Einträge, 2 Seiten |
1
2
3
4
5
6
[% INCLUDE header.tmpl %]
[% INCLUDE navigation.tmpl %]
<p>Mein Content</p>
[% INCLUDE footer.tmpl %]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[% BLOCK main %]
<html>
<head>
<title>[% title %]</title>
</head>
<body>
<ul>
[% FOREACH link = links %]
<li>[% link %]</li>
[% END %]
</ul>
[% content %]
</body>
</html>
[% END %]
1
2
3
4
5
6
[% WRAPPER main
title = 'Meine Homepage'
links = [ 'foo', 'bar', 'baz' ]
%]
<p>Mein Content</p>
[% END %]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use Template;
my $t = Template->new(
INCLUDE_PATH => '.',
PRE_PROCESS => 'main.tmpl'
) or die $!;
open my $fh, '<', 'index.tmpl' or die $!;
my $template = do { local $/; <$fh> };
close $fh;
while ( sleep 1 ) {
$t->process(\$template) or die $!;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<html>
<head>
<title>Meine Homepage</title>
</head>
<body>
<ul>
<li>foo</li>
<li>bar</li>
<li>baz</li>
</ul>
<p>Mein Content</p>
</body>
</html>
QuoteEs ist klar, dass man trotzdem etwas gewinnen kann, wenn alles schon als Perl-Skalar vorliegt, man spart schließlich ein paar Syscalls.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use strict;
use warnings;
use Benchmark;
use Template;
open my $fh, '<', 'index1.tmpl' or die $!;
my $template = do { local $/; <$fh> };
close $fh;
my $t1 = Template->new(INCLUDE_PATH => '.', PRE_PROCESS => 'main.tmpl') or die $!;
sub program { $t1->process(\$template, undef, '/dev/null') or die $!; }
sub cache { $t1->process('index1.tmpl', undef, '/dev/null') or die $!; }
Benchmark::cmpthese(-1, {
program => \&program,
cache => \&cache,
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use strict;
use warnings;
use Benchmark;
use Template;
open my $fh, '<', 'index.tmpl' or die $!;
my $template = do { local $/; <$fh> };
close $fh;
my $t1 = Template->new(INCLUDE_PATH => '.') or die $!;
sub program { $t1->process(\$template, undef, '/dev/null') or die $!; }
sub cache { $t1->process('index.tmpl', undef, '/dev/null') or die $!; }
Benchmark::cmpthese(-1, {
cache => \&cache,
program => \&program,
});
|< 1 2 >| | 15 Einträge, 2 Seiten |