Re: flexy enhancement
| From: | Sam Liddicott | Date: | Thu, 10 Jul 2003 18:05:37 +0000 |
| Subject: | Re: flexy enhancement | ||
| References: | 1 2 3 4 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-18144@lists.php.net to get a copy of this message | ||
Alan Knowles wrote:
Yes, I hadn't thought of how to do bulk re-compilation but I had seen from typo3 it could be a requirement rather than wait till the page requests come in and not be able to handle them at that point.So where I would have passed the internal parsed tag to a class generator and output a call to that class method in the outer context I now pass what would have been returned as $ret to my class generator (now global) and as $ret I return some php code to make the call.yeap - I would suggest passing $t into each method. as the first parameter. -It may take a bit of consultation with you to get this to work nicely. My class generator did track php/html state so as to only output <?php tags where neccessary and not where more code of the same type was being appended, which I suppose was more important when writing out a neat class defiintion as opposed to expanding out php. in token.php you say:yeah - at present I use the flexy:startchildren attribute to flag up the start of the output of the page. - earlier ideas used options in the compiler to say if you wanted to compile with/without header/html stuff. But that ran into problems when I needed to compile all templates in folder or something (for uploading to public servers etc.) if the template filename relates directly to the class name: eg. modules/navigation.html => Compiled_Templates_Modules_Naviagation and you just do $template = new HTML_Template_Flexy('modules/navigation.html'); $class = $template->compile($withelements); echo $class->body($this); It would be rather nice...// this whole children thing needs rethinking // - I think the body of the page should be wrapped: .. // ?php if (!$this->bodyOnly) { .. <HTML> .... <BODY....>?php } ? This was part of the reason behind parsing into a class, to make it easy to get rid of unwanted bits through subclassing and method overriding where needed, without littering the page with conditionals in case they were needed.
You should be able to override the superclass name when compiling the template, but in any case the programmer gets to choose which class the templates superclass subclasses from, so its not so important... Not only that, but now instead of : echo $class->body($this); it becomes echo $object->body(); No need for $t everywhere, instead $this, and so no need to pass $t parameters either.What if the generated class was a subclass of the controller class?mhh.. <html flexy:extends="MyProject_MainPage"> <body>..... </body> </html>
.. interesting idea here.. - might involve a bit of a rethink on some of my framework (again :).. - but the idea of templates pulling in pages, rather than my current controller pulling in a template may be an interesting idea..I'm not sure I understand, I thought the template was the page?
Yes, thats a good idea to automatically define methods for single use tags like html, head, title and bodyWhat if you also had a chance to subclass that and call outputObject on an instance of that? What if you then didn't need to beause I'm suggesting parsing into a class by default instead of to regular page with embedded php, users need never know if they don't want to...even if the defaults where to build elementHtml elementBody and elementHeader() .. it may solve alot of other issues that I was toying with...
a few ideas to sleep on.. :)It's kept me awake with excitement