in reply to RFC: Template::YetAnother
domm wrote: So, once again, code (even rather trivial) mixed with the markup.
With all due respect, I think you are misunderstanding something. While minimizing the amount of code in a template is a Good Thing, the benefit of templates is not separating code from the presentation. It's decoupling the application logic and the presentation logic. Consider the following Template Toolkit snippet:
[% IF people; FOREACH person = people %] <td>[% person.last_name %]</td> <td>[% person.first_name %]</td> <td>[% person.department %]</td> [% END; # FOREACH person; ELSE %] <td colspan="3" class="warning">No people found</td> [% END; # end if %]
There's nothing wrong with that. We're not calculating overtime. We're not pulling department data from a database. In fact, we're doing nothing but controlling the presentation logic. By pushing the presentation logic back into the application, then the application needs to know how the data is to be presented. If later you need to change the presentation of the data, you're forced to change the application!
Of course, you could get around this by assembling your data and then passing it off to another portion of the code that knows about the presentation, but that portion of code is often referred to as a "template" :)
Cheers,
Ovid
New address of my CGI Course.
Silence is Evil
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: RFC: Template::YetAnother
by domm (Chaplain) on Nov 16, 2002 at 15:57 UTC |