laziness, impatience, and hubris | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Template::Toolkit is a great system.
One of the problems I find when making pages with lots of interactivity is that you want to make "subroutines" that create parts of the HTML. Example: in a CMS that I'm making - yes, another one - I have a page that lists the document tree, with "nieuw" links that open the editor for a new page. These links can be put on several parts of the page. To simplify this, i made a BLOCK, like so: Here, the page items are Class::DBI objects. Now, whenever I want to to show these links, I do:
TT uses the same syntax to include other templates, so if needed, I can move the BLOCK to a seperate file without having to change the calling code. By the way, I use a seperate hash-ref "form" to store the values I want to set in the form on the editor. This $form hashref is initially filled with the values from the CGI request, but it allows me to change the values in "form" (for instance, with data from the $page object from the database) but still have the original request object lying around if I need it. This is a nice seperation of concerns that is very much used in the Struts java MVC framework, and works pretty well for more complicated interactions. In reply to Re^2: Code and html separation - always or mostly doable?
by Joost
|
|