Re: Package Proposal: HTML_Template_Dummy

From: Date: Fri, 18 Jul 2003 19:57:29 +0000
Subject: Re: Package Proposal: HTML_Template_Dummy
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-18392@lists.php.net to get a copy of this message
Hi, Lukas,
Just reading your description makes it sound alot like Xipe, which we already have in PEAR. Therefore -1 on it. Either way if you have anything that is not yet in Xipe please tell us.
It does sound very Xipe-like, and I suppose it is, at least in its goal (templates using PHP not some pseudo-language). Except. ;-) Xipe is a compiling engine, and Dummy is not. Xipe compiles the template braces {} and other stuff into a target .php file, then executes the target file. Dummy templates use "real" <?php ... ?> tags (ugly though they may be) and include()s the template on call, which avoids the compiling step entirely (and the compile-change-checks as well). This is not so much for reasons of performance (although technically Dummy might be a bit faster for it), but for simplicity: at least one less step (and file directory) for the developer to think about. And you use "real," direct PHP, not the braces-substituted-for-tags indirect PHP. Xipe has built-in caching, and Dummy does not. I figure, if you want to cache stuff, and you're a PEAR devotee, you might be better off using PEAR Cache or Cache_Lite. (Proper use of Cache would avoid having to parse every Dummy template every time, of course.) (This is not to denigrate Xipe's caching in any way; it is well-thought-out and well-integrated.) Xipe is relatively complex (and rightfully so, for what it does), and Dummy is relatively simple, yet with much of the power of Xipe (the "PHP as template language" thing). Xipe does a lot of things Dummy does not: config files, pre- and post-filters, and so on, that are functional because Xipe is a compiling engine. Dummy can have no reply to that, because Dummy uses plain PHP files for templates, and does not pre- or post-process them in any way. Dummy is very simple to extend: create your own class as an extension of Dummy, add a method called MyMethod, and you can call it from inside your templates using $this->MyMethod() (because the template is include()ed on a fetch() or a display() call, $this refers to the current Dummy object). These, then, are what I would call the strengths of HTML_Template_Dummy over HTML_Template_Xipe: Dummy is simple, straightforward, very easily extensible, and it limits its behavior strictly to the parsing of display logic and the encapsulation of display methods. It may well be (in fact is likely) that I am misguided in this idea, and that it really is not suitable or not needed in PEAR. If such is the case, that's OK with me; I have found the Dummy class useful, and if I'm the only one who thinks it's good then I am still a happy man. But I like to share when I can. :-) -- pmj

« previous php.pear.dev (#18392) next »