Hi,
I wan to inform about new release of template framework for PHP5 – web.template. It will be complexly rewrite, and I add same new, I think interesting features.
From this release, you don’t must use assign method (but you still can). Now you can make something like this:
Make class file:
<?php
Class MyClass {
public function getHello() {
return ‘Hello world’;
}
}
?>
And in index.php for example:
<?php
$tpl = new WebTemplate();
$tpl->setCacheDir('/home/public_html/wt/Tests/templates/cache/');
$tpl->setCompileDir('/home/public_html/wt/Tests/templates/compile/');
$tpl->setTemplateDir('/home/public_html/wt/Tests/templates/templates/');
$tpl->addVarClass('className,
array('name'=>'MyClass',
'path'=>'./',
'extension'=>'.php')
); //by default class is looking in file with class.php extension
/*
or:
$tpl->addVarClass('class', new MyClass());
*/
$tpl->display('test_var2.tpl');
?>
And here you are template:
<b><wt:var name="className.hello"/></b>
So now template can ask your class about data that it required and only if template need it;-) Sorry for my English;-)
You can – of course – write you own modifiers, tags and resources (for example for store templates and cache in D😎.
Feel free to download, test it and submit any bugs and suggestions.
This template framework can be used with web.framework (MVC framework for PHP5 - http://webframework.sourceforge.net/).
You can looking for web.template here http://sourceforge.net/projects/webtemplate/.
Best regards,
Marcin Staniszczak