Re: Yet Another Template Engine (source attached)
| From: | Thomas Hurst | Date: | Sat, 19 May 2001 14:16:37 +0000 |
| Subject: | Re: Yet Another Template Engine (source attached) | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-399@lists.php.net to get a copy of this message | ||
On 12 May 2001 12:47:02 -0700, anders@ignition.dk (Anders Johannsen)
wrote:
> Now actually including source ;-)
Very short, very simple.. template stuff's very much a matter of taste,
so I think it's good to have a lot of choice here.
One thing that bugs me is that template stuff's put in HTML/ - templates
are nothing to do with HTML, they're (supposedly) output format
independent, so I would suggest the creation of a new Template/
hierachy.
I also have a nice template class using isotemplates (one file with
nested blocks defined within it), with variable modifiers -
[[TimeStamp|gmtime(time format)]], for example, or
[[|call:Class::method()]]), and probably future support for simple
[[|if(expression)]].
It's very fast (no silly preg_replace()/str_replace() loops), and I
intend to write a compiled version to help it scale further. Usage is
very similar to IT.php, ala:
$t = new SimpleTemplate('file');
$t->setBlock('/path/to/block');
$t->setVar(..); // supports (key,value), array(..) and objects
$t->addBlock();
It's not written with PEAR in mind, so the src style probably clashes.
In fact, I have some exceptions to it, which I might mention later..
--
Thomas 'Freaky' Hurst - freak@aagh.net - http://www.aagh.net/