Skip to content

Instantly share code, notes, and snippets.

@AxlH
Created February 11, 2012 15:38
Show Gist options
  • Save AxlH/1801008 to your computer and use it in GitHub Desktop.
Save AxlH/1801008 to your computer and use it in GitHub Desktop.
<?php error_reporting(E_ALL||E_STRICT);
ini_set('display_errors', 1);
//@author: Axl Hoogelander//
//@description: This template parser will be really usefull//
class Template{
private $assign = array();
private static $file;
public static function p($file){
if(!isset(self::$file)){
self::$file = $file;
}
return self::$file;
}
public function assign($key, $value){
$this->assign[$key] = $value;
}
public function output(){
$output = file_get_contents(self::$file.'.php');
foreach($this->assign as $key => $value){
$output = str_replace('{'.$key.'}', $value, $output);
}
return $output;
}
//TODO: add some checks on output, cuz this isn't really safe!
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment