Hi der lady's
Because i didn't had shit to do I started randomly on a TPL system.
Here is the code for you mothafackas
Hope this could be usefull for some people!PHP Code:<?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; } } }
Or not.
Byee!
- - - Updated - - -
idk why the PHP tag is really shitty right now....




Reply With Quote


