Page tree
Skip to end of metadata
Go to start of metadata


Einfache Template Klasse
<?php 
class Template {
  private $_scriptPath='templates/';//comes from config.php
  
  
  public $properties;
  public function setScriptPath($scriptPath){
    $this->_scriptPath=$scriptPath;
  }
  public function __construct($resp, $templatePath){
  	if (is_null($resp) ) $this->properties = array();
  	else $this->properties = $resp;
  	
  	if (is_null($templatePath)) {;}
  	else $this->_scriptPath=$templatePath;
  	
  	setlocale (LC_ALL, 'de_DE');

  	
  }
  public function render($filename){
	
   ob_start();
   if(file_exists($this->_scriptPath.$filename)){
     include($this->_scriptPath.$filename);
    } else throw new TemplateNotFoundException();
    return ob_get_clean();
  }
  public function __set($k, $v){
      $this->properties[$k] = $v;
  }
  public function __get($k){
      return $this->properties[$k];
  }
}
?>


  • No labels
Write a comment…