lass
* This is a HTML Template Class that supports:
+ nested dynamic blocks
+ FREE combination of blocks
+ user-defined variables
* Since PHP is a language designed to be embeded in HTML, but it is not
so perfect to be embedded in the HTML. For example, mass of HTML tags that are
generated by tools, such as DreamWeaver and FrontPage, make PHP programmer
hard to embed their code into the HTML files. The auto-generated HTML tags are
not friendly for humans.
* In another case, your boss might bother you to change the layout of
the homepage since your PHP code has embedded in. It is a boring job.
However, I consider that why engineer works so diligently is to improve his life.
So, I write this simple template class that is simplest template
class I've seen.
* This class also supports for WML and whatever is tag-based language.
* If you feel good, let me know. *^_^*
Louis 2003/04/29
Download:
LouisTemplate-1.0.tgz
LouisTemplate-0.1.0.tgz
* A closed-block :
The following is a block named "Block1".
<BLOCK NAME="Block1">
<P>This is a paragraph.</P>
</BLOCK NAME="Block1">
* A user-defined variable (enclosed with { and } ) :
{NumOfStock}
And, you can use Set() function to assign the value of 'NumOfStock' in the template.
* Simple example:
$lt = new LouisTemplate; // new object
$lt->LoadFromFile( "example.tpl" ); // Load template from file.
// Another way is LoadFromString().
$str = $lt->Copy( "ROOT" ); // Copy template "ROOT", a special block
// into $str, simply a string.
// By default, Copy() will recursive
// into deeper block as possible.
echo $lt->Set( $str, "Name", "Louis" );
// Set {Name} in $str to "Louis"
$lt->Dump(); // dump all blocks, for debug
* More example:
See example.php and example.tpl in the tar file.
Visitors: 