Re: Package Proposal: HTML_Template_Dummy
| From: | Paul M Jones | Date: | Sat, 19 Jul 2003 13:29:39 +0000 |
| Subject: | Re: Package Proposal: HTML_Template_Dummy | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-18431@lists.php.net to get a copy of this message | ||
cagET wrote:
functions like: options() checkbox() radio() cycle() date() javascript() stylesheet() should be as plugins - smth like in Smarty cause its a waste to load all this code when we dont use itI may be wrong here, but I think Smarty loads up all those plugins, modifiers, etc. at instantiation time (if it's registered, it gets loaded so it's available to templates immediately). Incidentally, those are more like "convenience" functions than core functionality. In theory, they could be completely removed and not change the function of HTML_Template_Dummy in any way. You could, in theory, duplicate the code in your template every time you needed, say, a set of checkboxes (because template code is just PHP, after all). I kept them in Dummy for two reasons. One, they serve as an example of how to extend Dummy to encapsulate your own display methods (the ones you yourself use most often). Two, because *I* use them over and over again and figured other people might use them as well. ;-) As far as "waste" goes: Please note that the total size of HTML_Template_Dummy is 12.5k even with all of the "extra" convenience functions (and it's a liberally-documented 12.5k -- strip the comments and it's even smaller). In a purely technical sense, you are exactly right: it is a "waste" to load the code when you may not use it; on the other hand, in a practical every-day sense, the "waste" is so small as to be insignificant in relation to the rest of the app, and even more insignificant in relation to full-up engines like Xipe and Smarty.
i see 2 ways of doing this: 1. create function for example "exec" to execute plugins $this->exec('htmlOptions', $data, $selected)I had considered this, but then you have to come up with a naming convention, and a way of registering the plugins, and a way of including the code to be "exec"uted into the class. Suddenly we're back to Smarty, where the display functions are all in the global namespace, which is one thing I'd like to avoid (on principle, anyway -- and by the time this discussion is over I may find that it's not really possible to do that).
2. or create seperate Plugin object and use object overloading (requires PHP 4.3) $Plugin->htmlOptions($data, $selected);I had not thought of that; I'll look into it. Sounds useful; thanks! -- pmj