Template processor class
This class is the primary interface to deal with template files: text files that can be transformed by a template engine. The template engine provided by PHP2Go supports basic templating tools, like variables substitution and include support, and advanced tools, such as condition/iteration tags, support for function calls, capture areas, nested repetition blocks.
To read more about the pattern understood by the template parser, please consult the examples included in the framework's distribution.
Located in /core/template/Template.class.php (line 56)
PHP2Go | --Component | --Template
| Class | Description |
|---|---|
| DocumentElement | Extends base template class adding buffering capability and some utility methods |
Holds the next instance number for all dynamic blocks already instantiated
Cache options
TemplateConfigFile instance
Points to the current dynamic block
Current block name (defaults to TP_ROOTBLOCK)
Parser instance
Capture control variables
Registered components
Config variables
Control structure that holds template's dynamic content: block instances and variables
Global template variables
Internal template variables
Modified time of the template's source
Inherited from Component
Component::$attributes
Component::$preRendered
Class constructor
Register a custom variable modifier
Modifiers can be specified in 3 different ways:
Assigns a variable
The $variable argument can be a hashmap of variables and values, a simple variable name (and so, must be present in the current active block) or a 'block.variable' expression, which allows to assign variables on the most recent instance of a different block (not the current one).
Assigns a variable by reference
The $variable argument can be a variable name or a 'block.variable' expression.
Creates a new instance of a given block and assigns a variable or a set of variables
Creates a new instance of a dynamic block
The dynamic block must be declared in the template source using the following syntax:
The recently created block is transformed into the active block, so that all subsequent assign operations will be applied on it
Builds and displays the template's output code
Builds and returns the template's output code
Get the name of the active block
Get all declared blocks
Returns FALSE when the template wasn't compiled yet.
Get all variables defined in a given block
If $blockName is missing, TP_ROOTBLOCK will be used.
Returns FALSE when the template wasn't compiled yet.
Get the current value of a variable
Just as isVariableDefined, this method accepts a 'block.variable' expression in the $variable argument.
Assigns a global template variable
Global template variables are available in all scopes. This means that, no matter which is the current block, you'll be able to use it.
Assigns an include block
The assignment of include blocks must be done before the parse() method is called.
Example:
Checks if a given block name is defined in the template source
The $block argument can be either a block name or a path in the blocks tree. Examples:
Checks if the template was already compiled
Checks if a given variable name is declared
The $variable argument can be either a variable name or a 'block.variable' expression. Examples:
Prepares the template to be rendered
Automatically called inside getContent and display.
Triggers the compilation of the template
This method must be called manually before the template is populated with content (variables, blocks). If cache is enabled, a previously compiled template will be loaded from the cache storage.
This method must be called only once.
Returns the template to the state immediately after the compilation
All assigned variables are cleared and all block instances are destroyed.
Enable cache and configure cache properties
Changes the internal pointer to a given block name
Example:
Set the tag delimiter type
This template engine currently supports 3 types of tag delimiters:
Internal method used to assign variables
Builds a full path of a variable, considering block index, block name, block instance and variable name
Given a block name, returns its last instance
Get the next item of a given loop
The loop can be an array, a hashmap, a DataSet instance or an ADORecordSet instance. For each type, there's a different way to fetch and return the next record.
Calculate the total iterations of a given loop
Internal method used to assign global variables
Initializes the internal control variables
Load a set of config variables
Loads global configuration settings
Used at runtime to pop a dynamic block from the block stack
Used at runtime to push a dynamic block onto the block stack
Inherited From Component
Component::Component()
Component::display()
Component::getAttribute()
Component::getContent()
Component::hasAttribute()
Component::onPreRender()
Component::setAttribute()
Component::__destruct()
Component::__toString()
Inherited From PHP2Go
PHP2Go::PHP2Go()
PHP2Go::equals()
PHP2Go::generateUniqueId()
PHP2Go::getClassName()
PHP2Go::getConfigVal()
PHP2Go::getLangVal()
PHP2Go::getObjectName()
PHP2Go::getParentName()
PHP2Go::hasDestructor()
PHP2Go::hashCode()
PHP2Go::isA()
PHP2Go::isSubclassOf()
PHP2Go::logError()
PHP2Go::raiseError()
PHP2Go::registerDestructor()
PHP2Go::registerShutdownFunc()
PHP2Go::retrieve()
PHP2Go::store()
PHP2Go::__toString()
Documentation generated on Sun, 07 Oct 2007 19:30:12 -0300 by phpDocumentor 1.3.2