Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

NanoTPL - Because I was Bored!!!

Newbie Spellweaver
Joined
Jan 9, 2013
Messages
71
Reaction score
12
Hi der lady's :wink:

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....
 
Experienced Elementalist
Joined
Jul 23, 2012
Messages
201
Reaction score
128
here you are, isn't this better?
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;
        }
    }
}

i doubt this will be usefully for us motherfuckerz or any people or animals or whatever, lol...
 
Intelligent DoucheBag
Loyal Member
Joined
Jan 5, 2008
Messages
1,698
Reaction score
288
Can't post big butt code anymore?
well here is a pastebin of my try;


Expressions from raintpl, too lazy to write them myself.
Most simple but still efficient view class.

Usage:

index?:
Code:
include('view.php');
$view  = new view();
$view->_set("Variable_Name", "Variable_Value");
$view->draw("test");

test.html:
Code:
<a href="place_you_wanna_go">link?</a>
<img src="yourimage.png">
{{Variable_Name}}

Output test.html:
Code:
(Will add http:// but vbulletin is messing up my code)
<a href="127.0.0.1/simple_view/place_you_wanna_go">link?</a>
<img src="yourimage.png">
Variable_Value
 
Last edited:
Joined
May 17, 2007
Messages
2,474
Reaction score
681
Can't post big butt code anymore?
well here is a pastebin of my try;


Expressions from raintpl, too lazy to write them myself.
Most simple but still efficient view class.

Usage:

index?:
Code:
include('view.php');
$view  = new view();
$view->_set("Variable_Name", "Variable_Value");
$view->draw("test");

test.html:
Code:
<a href="place_you_wanna_go">link?</a>
<img src="yourimage.png">
{{Variable_Name}}

Output test.html:
Code:
(Will add http:// but vbulletin is messing up my code)
<a href="127.0.0.1/simple_view/place_you_wanna_go">link?</a>
<img src="yourimage.png">
Variable_Value

You can use the paste tag:

[paste]rtuRzwpr[/paste]
 
Back
Top