A interesting shortcut

From: Date: Mon, 10 Jan 2005 13:12:12 +0000
Subject: A interesting shortcut
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-12135@lists.php.net to get a copy of this message
i was playing with some concepts of doing templates, and i used to use this before i started using smarty, and it was pretty nice, but then i wanted to abstract my site even more, and passing strings started to get confusing heh.. <?php class Template { public $parms = array(); private $error = array(); private $file; function __construct($file = null) {
		if(is_null($file))      $this->error[] = "Filename is null";
if(!file_exists($file)) $this->error[] = "Cannot Access File"; $this->file = file_get_contents($file); } public function Build() { if(count($this->parms) < 1) $this->error[] = "Parameter array is empty"; if(count($this->error) > 0){ foreach($this->error as $key => $value) { $print.= $value. "<br />\n"; } throw new Exception($print); } else { foreach ($this->parms as $key => $value) { $this->file = str_replace("{".$key."}", $this->parms[$key], $this->file); } return $this->file; } } } ?>

« previous php.smarty.general (#12135) next »