TemplateObject.object
Boundary Conditions
- Parse Template, no registrations
$template_obj = new TemplateObject();
$template_obj->ParseTemplate('TemplateObject.tmpl');
unset($template_obj);
DOCUMENT STARTS
[-TOKEN1-]
%TOKEN2-]
[-TOKEN3%
%TOKEN4%
TOKEN5-]
[-TOKEN6
TOKEN7
echo "*****Embedded PHP******" ?>
DOCUMENT ENDS
|
- Parse Template, register single token, with no value
$template_obj = new TemplateObject();
$template_obj->Register('TOKEN1','');
$template_obj->ParseTemplate('TemplateObject.tmpl');
unset($template_obj);
DOCUMENT STARTS
%TOKEN2-]
[-TOKEN3%
%TOKEN4%
TOKEN5-]
[-TOKEN6
TOKEN7
echo "*****Embedded PHP******" ?>
DOCUMENT ENDS
|
- Parse Template, register single token, change start tag
$template_obj = new TemplateObject();
$template_obj->template_var_start = '%';
$template_obj->Register('TOKEN2','***NEWVALUE***');
$template_obj->ParseTemplate('TemplateObject.tmpl');
unset($template_obj);
DOCUMENT STARTS
[-TOKEN1-]
***NEWVALUE***
[-TOKEN3%
%TOKEN4%
TOKEN5-]
[-TOKEN6
TOKEN7
echo "*****Embedded PHP******" ?>
DOCUMENT ENDS
|
- Parse Template, register single token, change end tag
$template_obj = new TemplateObject();
$template_obj->template_var_end = '%';
$template_obj->Register('TOKEN3','***NEWVALUE***');
$template_obj->ParseTemplate('TemplateObject.tmpl');
unset($template_obj);
DOCUMENT STARTS
[-TOKEN1-]
%TOKEN2-]
***NEWVALUE***
%TOKEN4%
TOKEN5-]
[-TOKEN6
TOKEN7
echo "*****Embedded PHP******" ?>
DOCUMENT ENDS
|
- Parse Template, register single token, change both end and start tags
$template_obj = new TemplateObject();
$template_obj->template_var_start = '%';
$template_obj->template_var_end = '%';
$template_obj->Register('TOKEN4','***NEWVALUE***');
$template_obj->ParseTemplate('TemplateObject.tmpl');
unset($template_obj);
DOCUMENT STARTS
[-TOKEN1-]
%TOKEN2-]
[-TOKEN3%
***NEWVALUE***
TOKEN5-]
[-TOKEN6
TOKEN7
echo "*****Embedded PHP******" ?>
DOCUMENT ENDS
|
- Parse Template, register single token, change start tag to NOTHING!
$template_obj = new TemplateObject();
$template_obj->template_var_start = '';
$template_obj->Register('TOKEN5','***NEWVALUE***');
$template_obj->ParseTemplate('TemplateObject.tmpl');
unset($template_obj);
DOCUMENT STARTS
[-TOKEN1-]
%TOKEN2-]
[-TOKEN3%
%TOKEN4%
***NEWVALUE***
[-TOKEN6
TOKEN7
echo "*****Embedded PHP******" ?>
DOCUMENT ENDS
|
- Parse Template, register single token, change end tag to NOTHING!
$template_obj = new TemplateObject();
$template_obj->template_var_end = '';
$template_obj->Register('TOKEN6','***NEWVALUE***');
$template_obj->ParseTemplate('TemplateObject.tmpl');
unset($template_obj);
DOCUMENT STARTS
[-TOKEN1-]
%TOKEN2-]
[-TOKEN3%
%TOKEN4%
TOKEN5-]
***NEWVALUE***
TOKEN7
echo "*****Embedded PHP******" ?>
DOCUMENT ENDS
|
- Parse Template, register single token, change end and start tags to NOTHING!
$template_obj = new TemplateObject();
$template_obj->template_var_start = '';
$template_obj->template_var_end = '';
$template_obj->Register('TOKEN7','***NEWVALUE***');
$template_obj->ParseTemplate('TemplateObject.tmpl');
unset($template_obj);
DOCUMENT STARTS
[-TOKEN1-]
%TOKEN2-]
[-TOKEN3%
%TOKEN4%
TOKEN5-]
[-TOKEN6
***NEWVALUE***
echo "*****Embedded PHP******" ?>
DOCUMENT ENDS
|
Regular Conditions
Enable Imbedded PHP
$template_obj = new TemplateObject();
$template_obj->with_php = true;
$template_obj->ParseTemplate('TemplateObject.tmpl');
unset($template_obj);
DOCUMENT STARTS
[-TOKEN1-]
%TOKEN2-]
[-TOKEN3%
%TOKEN4%
TOKEN5-]
[-TOKEN6
TOKEN7
*****Embedded PHP******
DOCUMENT ENDS
|
Enable Returning of Contents
$template_obj = new TemplateObject();
$template_obj->return_contents = true;
$returned = $template_obj->ParseTemplate('TemplateObject.tmpl');
echo "<ul>$returned</ul>";
unset($template_obj);
DOCUMENT STARTS
[-TOKEN1-]
%TOKEN2-]
[-TOKEN3%
%TOKEN4%
TOKEN5-]
[-TOKEN6
TOKEN7
echo "*****Embedded PHP******" ?>
DOCUMENT ENDS
|
Enable Imbedded PHP _AND_ Returning of Contents
$template_obj = new TemplateObject();
$template_obj->with_php = true;
$template_obj->return_contents = true;
$returned = $template_obj->ParseTemplate('TemplateObject.tmpl');
echo "<ul>$returned</ul>";
unset($template_obj);
DOCUMENT STARTS
[-TOKEN1-]
%TOKEN2-]
[-TOKEN3%
%TOKEN4%
TOKEN5-]
[-TOKEN6
TOKEN7
*****Embedded PHP******
DOCUMENT ENDS
|
DOCUMENT STARTS
[-TOKEN1-]
%TOKEN2-]
[-TOKEN3%
%TOKEN4%
TOKEN5-]
[-TOKEN6
TOKEN7
echo "*****Embedded PHP******" ?>
DOCUMENT ENDS
|
Register Single File
$template_obj = new TemplateObject();
$template_obj->RegisterFile('TOKEN1','TemplateObject.file');
$template_obj->ParseTemplate('TemplateObject.tmpl');
unset($template_obj);
DOCUMENT STARTS
***Start TemplateObject.file***
[-TOKEN2-]
echo "*** EMBEDDED TemplateObject.file PHP ***"; ?>
***End TemplateObject.file***
%TOKEN2-]
[-TOKEN3%
%TOKEN4%
TOKEN5-]
[-TOKEN6
TOKEN7
echo "*****Embedded PHP******" ?>
DOCUMENT ENDS
|
Register Token with File, Enable Returning of Content
$template_obj = new TemplateObject();
$template_obj->return_contents = true;
$template_obj->RegisterFile('TOKEN1','TemplateObject.file');
$returned = $template_obj->ParseTemplate('TemplateObject.tmpl');
echo "<ul>$returned</ul>";
unset($template_obj);
DOCUMENT STARTS
***Start TemplateObject.file***
[-TOKEN2-]
echo "*** EMBEDDED TemplateObject.file PHP ***"; ?>
***End TemplateObject.file***
%TOKEN2-]
[-TOKEN3%
%TOKEN4%
TOKEN5-]
[-TOKEN6
TOKEN7
echo "*****Embedded PHP******" ?>
DOCUMENT ENDS
|
Register Token with File, Enable Imbedded PHP
$template_obj = new TemplateObject();
$template_obj->with_php = true;
$template_obj->RegisterFile('TOKEN1','TemplateObject.file');
$template_obj->ParseTemplate('TemplateObject.tmpl');
unset($template_obj);
DOCUMENT STARTS
***Start TemplateObject.file***
[-TOKEN2-]
*** EMBEDDED TemplateObject.file PHP ***
***End TemplateObject.file***
%TOKEN2-]
[-TOKEN3%
%TOKEN4%
TOKEN5-]
[-TOKEN6
TOKEN7
*****Embedded PHP******
DOCUMENT ENDS
|
Register Token with File AND THEN Register it as a normal token
$template_obj = new TemplateObject();
retval( $template_obj->RegisterFile('TOKEN1','TemplateObject.file') );
retval( $template_obj->Register('TOKEN1','***RE-REGISTER***') );
retval( $template_obj->ParseTemplate('TemplateObject.tmpl'));
unset($template_obj);
return: true
return: false
DOCUMENT STARTS
***Start TemplateObject.file***
[-TOKEN2-]
echo "*** EMBEDDED TemplateObject.file PHP ***"; ?>
***End TemplateObject.file***
%TOKEN2-]
[-TOKEN3%
%TOKEN4%
TOKEN5-]
[-TOKEN6
TOKEN7
echo "*****Embedded PHP******" ?>
DOCUMENT ENDS
|
return: true
Register Token with File AND Register a second as a normal token
$template_obj = new TemplateObject();
retval( $template_obj->RegisterFile('TOKEN1','TemplateObject.file') );
retval( $template_obj->Register('TOKEN2','**SECOND TOKEN**') );
retval( $template_obj->ParseTemplate('TemplateObject.tmpl'));
unset($template_obj);
return: true
return: true
DOCUMENT STARTS
***Start TemplateObject.file***
**SECOND TOKEN**
echo "*** EMBEDDED TemplateObject.file PHP ***"; ?>
***End TemplateObject.file***
%TOKEN2-]
[-TOKEN3%
%TOKEN4%
TOKEN5-]
[-TOKEN6
TOKEN7
echo "*****Embedded PHP******" ?>
DOCUMENT ENDS
|
return: true