#!/usr/bin/env perl
use
5.010;
use
lib
"$ENV{HOME}/workspace/XML-LibXML-jQuery/lib"
;
use
lib
"$ENV{HOME}/workspace/Plift/lib"
;
my
$plift
= Plift->new(
paths
=> [
"$FindBin::Bin/plift"
],
enable_cache
=> 1 );
my
$tt
= Template->new(
INCLUDE_PATH
=> [
"$FindBin::Bin/tt"
] );
my
@jquery_cache
=
map
{
$_
->document->clone } jquery_parse_files();
cmpthese(
shift
|| 5000, {
'HTML::Template'
=> \
&html_template
,
'HTML::Template::Pro'
=> \
&html_template_pro
,
});
sub
plift {
my
$doc
=
$plift
->process(
"index-wrap"
);
my
$output
=
$doc
->as_html;
}
sub
plift_wrapper {
my
$doc
=
$plift
->template(
"index"
, {
wrapper
=>
'layout'
})->render;
}
sub
html_template {
my
$html_template
= HTML::Template->new(
path
=> [
"$FindBin::Bin/html_template"
],
filename
=>
'layout.html'
);
}
sub
html_template_pro {
my
$html_template
= HTML::Template::Pro->new(
path
=> [
"$FindBin::Bin/html_template"
],
filename
=>
'layout.html'
);
}
sub
pure {
my
$footer
= Template::Pure->new(
template
=> path(
"$FindBin::Bin/pure/footer.html"
)->slurp_utf8,
directives
=> []);
my
$header
= Template::Pure->new(
template
=> path(
"$FindBin::Bin/pure/header.html"
)->slurp_utf8,
directives
=> []);
my
$layout
= Template::Pure->new(
template
=> path(
"$FindBin::Bin/pure/layout.html"
)->slurp_utf8,
directives
=> [
'#content+'
=>
'content'
]
);
my
$index
= Template::Pure->new(
template
=> path(
"$FindBin::Bin/pure/index.html"
)->slurp_utf8,
directives
=> []);
my
$output
=
$index
->render({
layout
=>
$layout
,
header
=>
$header
,
footer
=>
$footer
,
});
}
sub
tt {
my
$output
=
''
;
$tt
->process(
'index.html'
, {}, \
$output
)
||
die
$tt
->error();
$output
;
}
sub
read_files {
my
$file
= path(
"$FindBin::Bin/pure/footer.html"
)->slurp_utf8;
$file
= path(
"$FindBin::Bin/pure/header.html"
)->slurp_utf8;
$file
= path(
"$FindBin::Bin/pure/layout.html"
)->slurp_utf8;
$file
= path(
"$FindBin::Bin/pure/index.html"
)->slurp_utf8;
}
sub
jquery_parse_files {
my
@parsed
= (
j(path(
"$FindBin::Bin/pure/footer.html"
)->slurp_utf8),
j(path(
"$FindBin::Bin/pure/header.html"
)->slurp_utf8),
j(path(
"$FindBin::Bin/pure/layout.html"
)->slurp_utf8),
j(path(
"$FindBin::Bin/pure/index.html"
)->slurp_utf8),
);
}
sub
jquery_clone_nodes {
my
@clones
=
map
{
my
$dom
=
$_
->clone->contents;
$dom
->append_to(
$dom
->document);
$dom
;
}
@jquery_cache
;
}