NanoTPL - Because I was Bored!!!

Results 1 to 6 of 6
  1. #1
    Member TR10G33K is offline
    MemberRank
    Jan 2013 Join Date
    NetherlandsLocation
    71Posts

    cool NanoTPL - Because I was Bored!!!

    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
    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;        }    }        }
    Hope this could be usefull for some people!

    Or not.

    Byee!

    - - - Updated - - -

    idk why the PHP tag is really shitty right now....


  2. #2
    The Gamma..? EliteGM is offline
    MemberRank
    Jul 2006 Join Date
    NandolandLocation
    4,078Posts

    Re: NanoTPL - Because I was Bored!!!

    Syntax? Examples?

  3. #3
    Digital Horizon KristiansJ is offline
    MemberRank
    Jul 2012 Join Date
    203Posts

    Re: NanoTPL - Because I was Bored!!!

    here you are, isn't this better?
    PHP Code:
    /***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...

  4. #4
    Intelligent DoucheBag jur13n is offline
    MemberRank
    Jan 2008 Join Date
    Zwolle,Location
    1,946Posts

    Re: NanoTPL - Because I was Bored!!!

    Can't post big ass code anymore?
    well here is a pastebin of my try;
    http://pastebin.com/rtuRzwpr

    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 by jur13n; 28-03-14 at 05:19 PM.

  5. #5
    The next don TheAJ is offline
    DeveloperRank
    May 2007 Join Date
    Toronto, CanadaLocation
    3,946Posts

    Re: NanoTPL - Because I was Bored!!!

    Quote Originally Posted by jur13n View Post
    Can't post big ass code anymore?
    well here is a pastebin of my try;
    http://pastebin.com/rtuRzwpr

    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:


  6. #6
    Intelligent DoucheBag jur13n is offline
    MemberRank
    Jan 2008 Join Date
    Zwolle,Location
    1,946Posts

    Re: NanoTPL - Because I was Bored!!!

    Quote Originally Posted by TheAJ View Post
    You can use the paste tag:

    Thanks, didn't know that qq



Advertisement