PHP Classes

File: fasttemplate_example.php

Recommend this page to a friend!
  Classes of Jesus M. Castagnetto   Generalized CachedTemplate class   fasttemplate_example.php   Download  
File: fasttemplate_example.php
Role: ???
Content type: text/plain
Description: Example using the FastTemplate class
Class: Generalized CachedTemplate class
General Template Caching class
Author: By
Last change:
Date: 23 years ago
Size: 1,687 bytes
 

Contents

Class file image Download
<?php /* * $Id: fasttemplate_example.php,v 1.3 2000/07/16 19:33:46 jesus Exp $ */ // This test file is a simple modification of a // sample file include in FastTemplate require "./class.FastTemplate.php3"; require "./class.FastTemplateAdaptor.php"; require "./class.CachedTemplate.php"; $ftpl = new CachedTemplate(); $ftpl->init("./templates"); // for benchmarking $start = $ftpl->utime(); // the templates are distributed w/FastTemplate // we need this definition first, so the new logic can // detect if the templates have changed. $ftpl->define( array( main => "main.tpl", table => "table.tpl", row => "row.tpl" ) ); // Check if we can send the cached file if ($ftpl->valid_cache_file()) { echo "<B>FROM CACHE</B>\n<BR>"; $ftpl->read_from_cache(); $end = $ftpl->utime(); $runtime = ($end - $start) * 1000; echo "Completed in $runtime miliseconds<BR>\n"; exit; } // Otherwise process the page $ftpl->assign( array( TITLE => "FastTemplate Test") ); for ($n=1; $n <= 3; $n++) { $Number = $n; $BigNum = $n*10; $ftpl->assign( array( NUMBER => $Number, BIG_NUMBER => $BigNum ) ); $ftpl->parse(ROWS,".row"); } $ftpl->parse(MAIN, array("table","main")); // get parsed document $data = $ftpl->getParsedDoc(); echo $data; // for benchmarking $end = $ftpl->utime(); $runtime = ($end - $start) * 1000; echo "Completed in $runtime miliseconds<BR>\n"; // we write the file at the end so this // operation will not be counted in the benchmark $ftpl->write_to_cache($data); ?>