You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Gnieark 119485f334 test travis 2 years ago
sample addSubBlocsDefinitions 2 years ago
test addSubBlocsDefinitions 2 years ago
.gitignore gitignore 2 years ago
.travis.yml test travis 2 years ago
Makefile Source code now conforms to PSR-2 2 years ago improve Readme 2 years ago
TplBlock.php hhvm 2 years ago
autoload.php Trying with a custom autoload.php 2 years ago
composer.json Trying with PHPUnit v5.7 2 years ago
composer.lock permit fun with spaces 2 years ago
phpcs.xml Source code now conforms to PSR-2 2 years ago
phpmd.xml Source code now conforms to PSR-2 2 years ago


A very simple PHP template class

Build Status


This simple template file:

    <!-- BEGIN templatesystem -->
        <li><a href="{{templatesystem.url}}"> {{}}</a>
         by {{}} is {{templatesystem.quality}}</li> 
    <!-- END templatesystem -->


Parsed with this code:

require_once ("path/TplBlock.php");

//init object
$tpl = new TplBlock();
//add a var
$tpl->add_vars(array("pageTilte" => "Poke @zigazou ;)"));

$data = array(
        "url"       => "",
        "name"      => "tplBlock",
        "author"    => "Gnieark",
        "quality"   => "simple and perfect"
        "url"       => "",
        "name"      =>  "TemplateEngine",
        "author"    => "Zigazou",
        "quality"   => "more complex than tplBlock"


//add blocks
foreach ($data as $block){
    $tplTemplateSystem = new TplBlock("templatesystem");
    $tplTemplateSystem -> add_vars($block);

echo $tpl->apply_tpl_file("template.html");

will return:

    <h1>Poke @zigazou ;)</h1>
            <li><a href=""> tplBlock</a>
         by Gnieark is simple and perfect</li> 
            <li><a href=""> TemplateEngine</a>
         by Zigazou is more complex than tplBlock</li> 


Conception choices

I wrote this class for use it on others personnals projects. It’s really simple. I think logicals functions “OR” “IF”, filtering, caching, are not the templating system matter.

If a block ( <--BEGIN .... )is in the template, but is not called, it will be deleted.

For now, class is permissive. I’ll improve it to manage templating errors.


Use composer etc... or simply put the file TplBlock.php on your project


See the comments on the TplBlock.php file.