Re: [PHP3] Template Discussion

From: Date: Thu, 23 Mar 2000 12:45:09 +0000
Subject: Re: [PHP3] Template Discussion
References: 1  Groups: php.template 
Request: Send a blank email to php-template+get-445@lists.php.net to get a copy of this message
Rasmus Lerdorf wrote: > Just to give some idea of the concept here. Take this line of template > code: > > <html><#my special tag#></html> > > The template definition file behind it might look something like this: > > tag-start: <# > tag-end: #> > entity start { > name: my > args: arg1 arg2 > map_to_php_function: my(arg1,arg2) > } > > With only a couple of minor changes to the template definition file the > exact same result could be had by doing something like: > > <html>[my]</html> > > The template definition file behind it might look something like this: > > tag-start: [ > tag-end: ] > entity start { > name: my > map_to_php_function: my('sepcial','tag') > } > See, this is only just syntactic sugar. It does not really matter if you write <#my special tag#> or [my special tag] or, for that matter <my special tag>. The important thing happening here is that you are now parsing HTML/XML instead of just copying it to the output stream and scanning it for PHP processing instructions. This is absolutely great and goes much beyond the power of the template system as is proposed until now. Until now the template system is just manipulating flat text with regexps and - if Andrei has his way - control structures. This is nothing new compared to PHP with here documents. Actually parsing the HTML/XML document structure and being able to manipulate it as a tree of objects is something new and much more powerful (it is also slower). There really is no need to support different tag separators like <#, [ or < - we were able to live with < just fine in HTML until now. The important thing is to actually create the DOM object tree and work with current PHP upon this tree. And we already have a library that does this in PHP4, which is the severely underdocumented and highly experimental DomXML extension by U. Steinmann. Inflammatory personal opinion: In my not so humble opinion that should become the PHP template system and the current template approach should be abandoned, because it does not contain anything that can't be done with if() and here documents. But I suggested thing like that back in the days of PHP3 RC2, and got toasted for that. 1/2 :-) Kristian -- Kristian Köhntopp, NetUSE Kommunikationstechnologie GmbH Siemenswall, D-24107 Kiel, Germany, +49 431 386 436 00 Using PHP3? See our web development library at http://phplib.netuse.de/ (We have moved! Update your bookmarks!)

« previous php.template (#445) next »