good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re^3: Code and html separation - always or mostly doable?by amw1 (Friar) |
on Jun 16, 2004 at 14:33 UTC ( [id://367252]=note: print w/replies, xml ) | Need Help?? |
Another feature of TT that works well with blocks is the macro stuff. It allows you to write "functions" to do various things. i.e.
this takes a scalar and a list or scalar. If the scalar matches the other scalar or matches a value in the list the macro resolves to "selected" otherwise it does nothing. (used to find selected values in a <select> list. This lets you do things like. . . . I have not seen anything in HTML::Template that will let me come close to being able to do this. Most of the work that the template is doing would have to be shifted into the perl code. with html::Template (afaik, I stopped using after I got approval to use TT). In the above example option_list is a hash (that for sake of argument I got from a library call that I don't control). In H::T I'd have to re-write that structure into an array, I'd also have to resolve the selected attribute inside the perl code. The only place where those things are needed are for the display, so why should they be in the perl code. Granted, there is logic in the templates now, but it is solely DISPLAY logic. It is not processing logic. The split I try to get is to not have ANY display logic in the perl code and to not have ANY processing logic in the template. Stuff like properly formatting a date gets put into the template. Stuff like cooking data before it is put into the database lives in the perl code. There seems to be a fairly large camp that does not want to put any logic inside the templates. They are right too. :) Sorry if this is a bit long winded but I really enjoy working with this stuff.
In Section
Seekers of Perl Wisdom
|
|