| 
<?php
 require_once('template.class.php');
 require_once('template.commands.php');
 
 session_start();
 
 $template = new template('template.demo.php');
 
 
 addTemplateCommands($template);
 
 $template->add_command('includeStyles', function ($params) use ($template){
 return '<link rel="stylesheet" type="text/css" href="'.$params[0].'"/>'."\r\n";
 });
 
 $template->add_command('includeScript', function ($params) use ($template){
 return '<script type="text/javascript" src="'.$params[0].'"></script>';
 });
 
 
 $template->set_macros(array(
 'HeaderFile' => 'demo.header.php',
 'FooterFile' => 'demo.footer.php',
 'ScriptsFile' => 'demo.scripts.js',
 'StylesFile' => 'demo.styles.css',
 'PageTitle' => 'Benefits of using a Templating Engine',
 'BenefitsOfTemplates' => array(
 'Abstraction between Code & Output',
 'Simplification of Output Handling',
 'Sandboxing User Created Layouts',
 'Easier for Non-programmmers to Write/Read',
 'Easy data handoff between Front-End & Back-End Developers',
 'Simple data escaping implementation'
 )
 ));
 
 
 $template->add_macro('isLoggedIn', (bool)(isset($_SESSION['UserName'])));
 $template->add_macro('signInLink', 'demo.signin.php');
 
 if(isset($_SESSION['UserName'])){
 $template->add_macro('UserName', $_SESSION['UserName']);
 }
 
 echo $template->render();
 
 exit();
 
 ?>
 |