When using HTML_Template_PHPLIB to generate HTML or other code from templates, you do the following steps:
Create template class instance
Load template file
Define blocks
Set variables, parse blocks
Finish and output
Variables are placeholders in your HTML code
that can be replaced with dynamic values provided from database or
calculated in your code. An example for a variable is
{CODE_AUTHOR}
: You enclose the variable
name in curly braces. The name of the variable may contain
any characters, except spaces, tabs and newlines.
Blocks surround certain pieces of HTML code
and can be re-used, e.g. a <tr>
row in a table.
Blocks are defined by using HTML comments, containing
BEGIN
or END
, and the block name.
Example:
<table> <caption>Authors</caption> <thead> <tr><th>Name</th><th>Email</th></tr> </thead> <tbody> <!-- BEGIN authorline --> <tr><td>{AUTHOR_NAME}</td><td>{AUTHOR_EMAIL}</td></tr> <!-- END authorline --> </tbody> </table>