From: Jim B. <cb...@bu...> - 2005-04-28 11:51:41
|
For standard header/footer stuff for pages, we take care of this on the template side since this tends to be view-like information. We put it in our wrapper.tt (along with error-handling code) so it gets run for each page. Then each page.tt only needs to handle display duties for the middle part of the page. With Template Toolkit, you can use INCLUDE to pull in other templates easily in the display phase. If you have dynamic data in your headers and footers, you can handle that a few ways. The easiest is probably to add subs to your App.pm base class and call back to them from TT. Since self is sent to the template, you can call any of the methods from there. Another way is to create new slots, generate the data in your pm files, stick the data in the slot, then reference it from the Template. In general, I've found that one pm = one page, so you usually won't create separate pm files for smaller components. If it is a shared component, you can stick it in App.pm. And for what it's worth, CGI::Prototype::Hidden adds some nice features, so you may consider checking that out. Hope this helps. Jim On Apr 28, 2005, at 1:25 AM, LD wrote: > Hi there, > > obviously an active list :-) > > Anyway - I'm so far really liking CGI::Prototype (with its simple MVC > implementation) but what I'm not clear on is the best way to > incorporate Reusable Components. > > Say you've got the following components which all inherit from > CGI::Prototype... > > Header: (reusable) > /Header.pm > /Header.tt > > Various Pages: > /Main.pm > /Main.tt > /Login.pm > /Login.tt > <...> > > Footer: (reusable) > /Footer.pm > /Footer.tt > > ...and somecgi.cgi which basically does > Main->activate; > > What's the best way of including the output of Header and Footer in > the render phase - i.e., as if you'd concated the output of: > Header->activate; Main->activate; Footer->activate; > > Any thoughts? > > Cheers, > LD > > > > ------------------------------------------------------- > SF.Net email is sponsored by: Tell us your software development plans! > Take this survey and enter to win a one-year sub to SourceForge.net > Plus IDC's 2005 look-ahead and a copy of this survey > Click here to start! http://www.idcswdc.com/cgi-bin/survey?id=105hix > _______________________________________________ > cgi-prototype-users mailing list > cgi...@li... > https://lists.sourceforge.net/lists/listinfo/cgi-prototype-users > ========================================== Jim Brandt Administrative Computing Services University at Buffalo |