Re: flexy enhancement

From: Date: Thu, 10 Jul 2003 15:13:14 +0000
Subject: Re: flexy enhancement
References: 1 2 3  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-18138@lists.php.net to get a copy of this message
Sam Liddicott wrote:
"Alan Knowles" <alan@akbkhome.com> wrote in message news:3F0CC2BB.2030205@akbkhome.com...
Sam Liddicott wrote:
I'm requesting comment on a new templating enhancement I thought of and
     
am
working on, which I wish to contribute to XIPE.
     
Interesting idea.. - you know that you could add this in about 10 lines of code to Flexy? - just modify the toHtml part of HTML_Template_Flexy_Token_Tag to check for the method attribute.. and store the methods in a static global... then output later..
do you mean toString ? yeap :)
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:
           // 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. 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...
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.. -
What 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.. :) Regards Alan
Sam


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