On Wed, 2009-03-04 at 21:42 -0700, Nathan Nobbe wrote: > On Wed, Mar 4, 2009 at 7:01 PM, Michael A. Peters <mpet...@mac.com> wrote: > > > echoing html involves mixing html and php. > > Using an XML class (like DOMDocument) to build the document does not. > > > ive actually written a little templating system which subclasses > SimpleXMLElement to achieve just that, take a peak at the syntax if you like > (any feedback appreciated), > > http://nathan.moxune.com/phacadeDemo/ > > the syntax toward the bottom is what i really liked when i was starting > out. the demo page is about as far as i got w/ it, though. what i ended up > not liking about it, is how its joined at the hip w/ xml. suppose i want to > template other things,.. css, js, php all come to mind. > > i could do that w/ pure php, and im sure any of these other systems such as > smarty could let you template things beyond a subset of xml. what i like > about this blitz module, and Rob's TemplateJinn, is an additional emphasis > on performance.
That was one of the reasons I wrote the TemplateJinn parser from scratch. It isn't dependent on XML. The custom tag aspect (only one part) of it uses XML-like tag syntax, but it does not require that an entire document be XML compliant nor even XML-like at all. This allows the tags to be applied to older non-compliant documents, partial documents, non tag documents, etc. > the other thing that i cant understand in general about templating is the > whole notion of making things easier for so-called "designers", ui folks or > w/e, who arent used to 'code'. in my personal experience, i have yet to see > anyone actually doing that right, or anything close to it in a real > environment. im not trying to say there is one way and only one way to use > a templating system, but im just saying that is a halmark benefit, which i > dont think ive ever seen in practice.. what i see is programmers using them > b/c they feel its hepling them separate presentation and logic. I've had non programmers use my template engine, and they've not had a problem. That doesn't mean to say it wasn't primarily developed for my own use, but having a tag structure makes it fairly easy for anyone using tags to understand. > that said, i think folks really should look at what templating solutions are > doing or can do in their environment. i dont know, most templating systems > look pretty similar to me from a distance, smarty & savant look > fundamentally similar. you have a class which you populate with data, and > then those are mapped into placeholders in template files. the rest of the > differences seem skin deep to me, but if im missing something, id love to > know. There are different philosophies for how template engines work. For instance Smarty uses a push system-- you initialize the template, assign variable values, and smarty pushes the values to the template, then returns the final content. TemplateJinn generally works the other way... the template declares one or more modules (or makes use of a pre-loaded module), the template includes tags that pull data from the module. Since it's compiled to the final page, or PHP source that would be included, then the data is pulled at run-time and the need for the template processor is removed at run-time. TemplateJinn can work the other way also... but I find it more natural for the template to declare what it wants and to pull data from the module than the other way around. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php