| 
<?
define ('GZIP',        FALSE);        // GZip support
 define ('DEBUG',    TRUE);        // If TRUE, compiled templates not cached
 
 require_once '/lib/class.tpl.inc';
 
 // Engine initialisation
 $path = dirname(__FILE__);
 $tpl = new tpl('test', $path."/templates/new", $path."/templates");
 
 $g = array(
 'r' => array(255, -8),
 'g' => array(255, -6),
 'b' => array(255, -4),
 );
 
 $lines = array();
 for ($i = 1; $i < 10; $i++) {        // Nested LOOP initialization
 $cells = array();
 for ($j = 1; $j < 10; $j++) {
 $k = $i * $j;
 array_push($cells, array('var1' => $k, 'odd' => $k % 2));
 }
 array_push($lines, array('cols' => $cells, 'color' =>_gradient($g, $i)));
 }
 
 // Initialize 'root' variable
 $root = array(
 'rows' => &$lines,
 'title' => 'PHTML::Template 2.0',
 'sw' => 'three',
 );
 
 $tpl->done();
 
 /////////////////////////////////////////////////////////////////////
 // Aux functions
 /////////////////////////////////////////////////////////////////////
 
 function _gradient($args, $x) {        // Color gradient generation
 // C + P * x;
 foreach ($args as $c => $p)
 $$c = (string)bin2hex(chr((string)(array_shift($p) + array_shift($p) * $x)));
 return strtoupper($r.$g.$b);
 }
 
 ?>
 
 |