openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

TemplateRunner.class.php (950B)


      1 <?php
      2 
      3 
      4 namespace template_engine\engine;
      5 use DomainException;
      6 use DOMDocument;
      7 use DOMElement;
      8 use Exception;
      9 use LogicException;
     10 use template_engine\element\XMLFormatter;
     11 use template_engine\element\PHPBlockElement;
     12 use template_engine\components\html\Component;
     13 use template_engine\components\html\NativeHtmlComponent;
     14 
     15 /**
     16  * Executes a template.
     17  *
     18  * @author Jan Dankert
     19  */
     20 class TemplateRunner
     21 {
     22 	/**
     23 	 * Executes the required template and writes the output to standard-out..
     24 	 *
     25 	 * @param $templateFile string filename of template
     26 	 * @param $outputData array output data
     27 	 */
     28     public function executeTemplate($templateFile, $outputData)
     29     {
     30         if ( ! is_file($templateFile) )
     31             throw new LogicException("Template file '$templateFile' was not found.");
     32 
     33 		// Extracting all output data into the actual context
     34         extract($outputData);
     35 
     36         // Include the template
     37         require_once($templateFile);
     38     }
     39 
     40 }
     41