PHP Classes
elePHPant
Icontem

File: demo.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Zubov Ilya  >  Solace FastTemplate  >  demo.php  >  Download  
File: demo.php
Role: Example script
Content type: text/plain
Description: Demonstration
Class: Solace FastTemplate
Remake of the FastTemplate engine
Author: By
Last change:
Date: 10 years ago
Size: 1,469 bytes
 

Contents

Class file image Download
<?
include('sftemplate.php');

   
// intialize class object with the path for template files (current folder)
   
$tpl = new FastTemplate('./');

   
// prepare template (this is a new function)
    // also automatically detect all dynamic blocks
    // (no need for define_dynamic() from original FastTemplate now)
   
$tpl->load('template');
   
   
// enable block 'bb' (it is disabled by default)
   
$tpl->enable_block('bb');
   
// disable block 'c' (it is enabled by default)
   
$tpl->disable_block('cc');

   
// nested dynamic parsing
   
for ($i=1; $i<=10; $i++) {
        for (
$j=1;$j<=$i;$j++) {
           
// assignment of variable
           
$tpl->assign('var1', $j);
           
// dynamic block 'cols' is parsed and appended
            // (. char before the name means to append, like in original FastTemplate)
            // into variable 'cells'
           
$tpl->parse('cells', '.cols');
        }
       
// parse and append 'rows' block
        // engine replaces dynamic block 'cols' with the content
        // from the variable used for it's parsing
       
$tpl->parse('lines', '.rows');
       
// clear variable 'cells' before a new table row
       
$tpl->clear('cells');
    }

   
// parse entire template
    // engine replaces dynamic block 'rows' with the content
    // from the variable with the same name 'rows'
   
$tpl->parse('main', 'template');
   
   
$tpl->FastPrint('main');

?>