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
- Host: GitHub
- URL: https://github.com/rsamaium/templates
- Owner: RSamaium
- Created: 2011-10-18T19:24:20.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2011-10-18T19:26:02.000Z (over 13 years ago)
- Last Synced: 2024-12-31T19:43:09.035Z (6 months ago)
- Language: PHP
- Homepage:
- Size: 87.9 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.txt
Awesome Lists containing this project
README
Templates 1.0
https://github.com/RSamaium/Templates
Required :
- PHP 5Creating 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}