An open API service indexing awesome lists of open source software.

https://github.com/rsamaium/templates

Creating Templates for MVC
https://github.com/rsamaium/templates

Last synced: 4 months ago
JSON representation

Creating Templates for MVC

Awesome Lists containing this project

README

        

Templates 1.0

https://github.com/RSamaium/Templates

Required :
- PHP 5

Creating Templates for MVC. Templates like phpBB

Example :

$template = new Templates("path/to/tpl/");
$template->assignVars(array(
"HELLOWORLD" => "Hello !"
));
$template->setTemplate("index.html");

File "index.html" in the "path/to/tpl/" :

{HELLOWORLD}

displays :

Hello !




Documentation :

{VAR} => Display the value of VAR. See "assignVars()"
=> Test the value of VAR. Condition.


=> Include a template (link defined in the constructor)
{test.VAR} => Displays the variable loop. See "assignBlockVars()"
{foo.bar.VAR}

Example :

$template = new Templates("tpl/");
$template->assignVars(array(
"POS" => "Position",
"COLOR" => "red"
));
for ($i=0 ; $i < 5 ; $i++) {
$template->assignBlockVars("tr", array(
"COLOR" => $i % 2 == 0
));
for ($j=0 ; $j < 5 ; $j++) {
$template->assignBlockVars("tr.td", array(
"VAL" => 'x:' . $i . ';y:' . $j
));
}
}
$template->setTemplate("index.html");

Template :

{POS} :


style="color: {COLOR}">

{tr.td.VAL}