HTML_Template_IT

HTML_Template_IT --  Light-weight template system

Placeholder

The format of placeholder is
{[0-9A-Za-z_-]+}
This means, the name of the placeholder can consist of upper- and lowercase letters, underscores and hypens. The name must be placed between curly brackets without any spaces. Valid names are i.e.:

{Placeholder}
{place2_holder}
{PLACEHOLDER1}
{Place-Holder}

Non-valid names are i.e.

{ Placeholder 3 } (spaces)
{place*holder} (char isn't permitted)

Blocks

The format of a block is
<!-- BEGIN [0-9A-Za-z_-]+ -->
... block content ...
<!-- END [0-9A-Za-z_-]+ -->
The rules for the block name are the same like for placeholders. In contrast to placeholders the spaces in the block markup are required.

The nesting of blocks is permitted, but be careful while parsing. You have to set and parse the deepest inner block first and then set and parse from inner to outer.

Usage Example

HTML_Template_IT::HTML_Template_IT

void HTML_Template_IT::HTML_Template_IT ([string $root])

Builds some complex regular expressions and optinally sets the file root directory. Make sure that you call this constructor if you derive your templateclass from this one.

Parameter

HTML_Template_IT::get

string HTML_Template_IT::get ([string $block])

Returns a block with all replacements done.

Parameter

HTML_Template_IT::parse

void HTML_Template_IT::parse ([string $block [, boolean $flag_recursion]])

Parses the given block.

Parameter

HTML_Template_IT::parseCurrentBlock

void HTML_Template_IT::parseCurrentBlock ()

Parses the current block

HTML_Template_IT::setVariable

void HTML_Template_IT::setVariable (mixed $placeholder [, string $variable])

Sets a variable value. The function can be used eighter like setVariable( "varname", "value") or with one array $variables["varname"] = "value" given setVariable($variables).

Parameter

HTML_Template_IT::setCurrentBlock

boolean HTML_Template_IT::setCurrentBlock ([string $block])

Sets the name of the current block, that is the block where variables are added.

Parameter

Returns

HTML_Template_IT::touchBlock

boolean HTML_Template_IT::touchBlock (string $block)

Preserves an empty block even if removeEmptyBlocks is true

Parameter

Returns

HTML_Template_IT::init

void HTML_Template_IT::init ()

Clears all datafields of the object and rebuilds the internal blocklist. LoadTemplatefile() and setTemplate() automatically call this function when a new template is given. Don't use this function unless you know what you're doing.

HTML_Template_IT::free

void HTML_Template_IT::free ()

Clears all datafields of the object. Don't use this function unless you know what you're doing.

HTML_Template_IT::setTemplate

void HTML_Template_IT::setTemplate (string $template)

Sets the template. You can eighter load a template file from disk with LoadTemplatefile() or set the template manually using this function.

Parameter

HTML_Template_IT::loadTemplatefile

boolean HTML_Template_IT::loadTemplatefile (string $filename [, boolean $removeUnknownVariables [, boolean $removeEmptyBlocks]])

Reads a template file from the disk.

Parameter

Returns

HTML_Template_IT::setRoot

void HTML_Template_IT::setRoot (string $root [, boolean $removeUnknownVariables [, boolean $removeEmptyBlocks]])

Sets the file root. The file root gets prefixed to all filenames passed to the object.

Parameter

HTML_Template_IT::show

void HTML_Template_IT::show ([string $block])

Print a certain block with all replacements done.

Parameter