PHPLib ((http://phplib.netuse.de/) is a collection of classes for various
web objects (authentication, shopping cart, sessions, etc), but what we're
interested in is the Template
object. It's much more primitive than
Smarty, and was based on an old Perl template class. In fact, one of the
precursors to Cheetah was based on it too. Differences from Cheetah:
{placeholders}
in braces.
set_var
method. However, you can pass
this method an array (dictionary) of several variables at once.
<!-- BEGIN blockName --> ...
<!-- END blockName>
. The set_block
method extracts this text
into a namespace variable and puts a placeholder referring to it in the
template. This has a few parallels with Cheetah's #block
directive but is overall quite different.
#if
, extract the block. Then if true, do
nothing. If false, assign the empty string to the namespace variable.
#for
, extract the block. Set any
namespace variables needed inside the loop. To parse one iteration, use
the parse
method to fill the block variable (a mini-template) into
another namespace variable, appending to it. Refresh the namespace
variables needed inside the loop and parse again; repeat for each
iteration. You'll end up with a mini-result that will be plugged into the
main template's placeholder.
set_file
method. This places the file's content in a namespace variable.
To read a template definition from a string, assign it to a namespace
variable.