File modules/template_engine/engine/TemplateRunner.class.php
Last commit: Wed Nov 17 23:22:19 2021 +0100 Jan Dankert Refactoring: Using a template context for templates instead of the HTTP-Request-Data
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
Downloadmodules/template_engine/engine/TemplateRunner.class.php
History Wed, 17 Nov 2021 23:22:19 +0100 Jan Dankert Refactoring: Using a template context for templates instead of the HTTP-Request-Data Thu, 22 Oct 2020 13:49:13 +0200 Jan Dankert Refactoring: Generating the root HTML with a clean template.