<?php
// This test file is a simple modification of a
// sample file include in FastTemplate
require ("./class.FastTemplate.php3");
require ("./class.CachedFastTemplate.php");
$tpl = new CachedFastTemplate("./templates");
// for benchmarking
$start = $tpl->utime();
$filename = "yipeee.html";
// if the filename is empty, the class will use PHP_SELF
// the templates are distributed w/FastTemplate
// we need this definition first, so the new logic can
// detect if the templates have changed.
$tpl->define(
array(
main => "main.tpl",
table => "table.tpl",
row => "row.tpl"
)
);
// Check if we can send the cached file
if ($tpl->valid_cache_file($filename)) {
echo "<B>FROM CACHE</B>\n<BR>";
$tpl->read_from_cache($filename);
$end = $tpl->utime();
$runtime = ($end - $start) * 1000;
echo "Completed in $runtime miliseconds<BR>\n";
exit;
}
// Otherwise process the page
$tpl->assign( array( TITLE => "FastTemplate Test") );
for ($n=1; $n <= 3; $n++)
{
$Number = $n;
$BigNum = $n*10;
$tpl->assign(
array(
NUMBER => $Number,
BIG_NUMBER => $BigNum
)
);
$tpl->parse(ROWS,".row");
}
$tpl->parse(MAIN, array("table","main"));
$data = $tpl->fetch();
$tpl->write_to_cache($filename, $data);
$tpl->FastPrint();
// for benchmarking
$end = $tpl->utime();
$runtime = ($end - $start) * 1000;
echo "Completed in $runtime miliseconds<BR>\n";
exit;
?>
|