Newbie Spellweaver
- Joined
- Jan 9, 2013
- Messages
- 71
- Reaction score
- 12
Hi der lady's
Because i didn't had poop to do I started randomly on a TPL system.
Here is the code for you mothafackas
Hope this could be usefull for some people!
Or not.
Byee!
idk why the PHP tag is really crappy right now....
Because i didn't had poop to do I started randomly on a TPL system.
Here is the code for you mothafackas
PHP:
<?php /***NanoTPL**Basic and easy to use TPL system**2014 VIS000***/class TPL{ public function __construct() {} private $page, $base, $extention; public function SetBase($base) { if(is_dir($base)) { $this->base = $base; } else { $this->Exception(1); } } public function SetExtention($ext) { $this->extention = $ext; } public function Load($file) { if(file_exists($this->base .'/'.$file.'.'.$this->extention)) { $this->page = file_get_contents($this->base .'/'.$file.'.'.$this->extention); } else { $this->Exception(2); } } public function Assign($key, $value) { $this->page = str_replace('{'.$key.'}', $value, $this->page); } public function Render() { echo $this->page; } private function Exception($code) { switch($code) { case 1: die('NanoTPL Error: Base is not a known directory'); break; case 2: die('NanoTPL Error: Failed to load file'); break; default: return false; } } }
Hope this could be usefull for some people!
Or not.
Byee!
idk why the PHP tag is really crappy right now....