Created
February 11, 2012 15:38
-
-
Save AxlH/1801008 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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