Packageindex Classtrees Modulegroups Elementlist Report XML Files

XTPL Template Engine - XTPL

XTPL

XTPL

public class XTPL

XTPL template class. This is the main XTPL class and it provides you
easy-to-use template engine.

Authors Vladimir Sibirov <trustware@bk.ru>
Version XTPL, v.1.2
 

Public Method Summary

void

XTPL()

Constructor: creates new XTPL object.
void

Start([ boolean $gzip ])

Starts output buffering. You may control GZIP comperession of the ouput by the argument.
void

Flush()

Immediately flushes the output buffer.
void

End()

Flushes the output buffer and switches output buffering off.
bool

GZIP([ string $value ])

Sets the value of output buffer GZIP compression to $value if it is defined.
void

Assign(string $name, mixed $value)

Assigns a new private XTPL variable.
void

Unassign(string $name)

Removes the variable from the private assigned list.
void

ParseStr(string $content)

Parses string and sends result to output. You may use this function to parse the strings
void

Parse(string $filename)

Parses the template file.

Private Constant Summary

XTPL_GZIP >>false<< Defines whether to use GZIP compression of output buffer.

Public Method Details

XTPL

public void XTPL( )

  Constructor: creates new XTPL object.
It turns GZIP output compression on if XTPL_GZIP constant is true.
Example:
<?
define
('XTPL_GZIP', true);
$page = new XTPL();
?>

Returns void


Start

public void Start( [ boolean $gzip ] )

  Starts output buffering. You may control GZIP comperession of the ouput by the argument.
Output buffering allows you to send any headers, cookies and use session_ functions untilthe buffer is flushed. It also allows you to use GZIP output compression which helps tocompress the page size if the browser supports the compression (or the content is sentin standard way if GZIP compression is not supported).
Example:
<?
$page
= new XTPL();
$page->Start(true);
$page->Parse('tpl/template.tpl');
$page->End();
?>

Parameter
boolean $gzip = >>false<<
Output ZLib compression
Returns void


Flush

public void Flush( )

  Immediately flushes the output buffer.
Example:
<?
$page
= new XTPL();
$page->Start();
$page->Parse('tpl/template.tpl');
// flushing the buffer before another template is parsed
$page->Flush();
$page->Parse('tpl/another.tpl');
// End output buffering
$page->End();
?>

Returns void


End

public void End( )

  Flushes the output buffer and switches output buffering off.
Example:
<?
$page
->End();
// Now printing immediately
echo 'Hi, can you see this?';
?>

Returns void


GZIP

public bool GZIP( [ string $value ] )

  Sets the value of output buffer GZIP compression to $value if it is defined.
Otherwise returns current value of output buffer ZLib compression.
Example:
<?
$current_value
= $page->GZIP();
if(!
$current_value) $page->GZIP(true);
?>

Parameter
string $value = >>null<<
Returns bool


Assign

public void Assign( string $name, mixed $value )

  Assigns a new private XTPL variable.
When XTPL meet {$var} sequence it first looks for the replacement inthe private section. If the variable doesn't exist in the private sectionthen XTPL searches for it in the global scope.
Example:
<?
$id
= 25;
$page->ParseStr('id is {$id}');
// 25 is printed
$page->Assign('id', 10);
$page->ParseStr('id is {$id}');
// 10 is printed
?>

Parameter
string $name
$value
Value of the variable to assign
Returns void


Unassign

public void Unassign( string $name)

  Removes the variable from the private assigned list. Unassignes the variable which has been
assigned by XTPL::Assign() method.

Parameter
string $name
Returns void


ParseStr

public void ParseStr( string $content )

  Parses string and sends result to output. You may use this function to parse the strings
with XTPL syntax directly but it is not recommended.

Parameter
string $content
Returns void


Parse

public void Parse( string $filename )

  Parses the template file.
Example:
<?
$page
->Parse('template.tpl');
?>

Parameter
string $filename
Returns void


Private Constant Details

XTPL_GZIP

define( XTPL_GZIP, >>false<< )
Case: default: case sensitive




Packageindex Classtrees Modulegroups Elementlist Report XML Files
PHPDoc 1.0beta