<?
require_once 'Dextep.class.php';
$template = new Dextep();
$template->setVar('str', 'Hello, world!');
$template->setVar('bool', true);
$template->setVar('float', 3.5);
$template->setVar('array', array('key' => 'value', array('str', true, 3.5)));
echo '<strong>Pre-execution test:</strong><br />';
$template->setVar('array.key', 'upd');
echo 'testing setVar() and getVar()...<br />';
$result = $template->getVar('array.key').count($template->getVar('array.0'));
echo '<strong>'.($result == 'upd3' ? '<span style="color:green">ok</span>' : '<span style="color:red">error</span>').'</strong>';
echo '<br /><br />';
echo '<strong>Template "test":</strong><br />';
echo 'testing expressions, if, for, foreach, include, preparing for test2...<br />';
$result = $template->getTemplate('test', true);
echo '<strong>'.($result == '123.52{}key01' ? '<span style="color:green">ok</span>' : '<span style="color:red">error</span>').'</strong>';
echo '<br /><br />';
echo '<strong>Template "test2":</strong><br />';
echo 'testing @-prefix, local %-variables and global variable scope...<br />';
$result = $template->getTemplate('test2', true);
echo '<strong>'.($result == 'Hello, world!' ? '<span style="color:green">ok</span>' : '<span style="color:red">error</span>').'</strong>';
echo '<br /><br />';
echo '<strong>Self-inclusion test (last one):</strong><br />';
echo 'should see error message below. Here we go:<br /><br />';
$template->getTemplate('self', true);
?>
|