Jonathan Mangin wrote:
> I'm going nuts with this. How do you guys do it?
I'm not sure I follow the precise nature of the problem relating to
your particular data set, but the general answer to this kind of general
problem is "by abstraction".
I'd create a plugin module which splits the data up accordingly and
provides some nicely named methods to make it clear to anyone reading
the template about what's going on.
For example(s):
[% USE MyData(items) %]
[% FOREACH item IN MyData.in_category(6) %]
...
[% FOREACH item IN MyData.relating_to_customer(12345) %]
...
[% FOREACH item IN MyData.between_dates(20050801, 20050901) %]
...
# or the all-in-one select() method approach
[% FOREACH item IN MyData.select( category = 6,
customer = 12345,
start_date = 20050801,
end_date = 20050901 ) %]
Then everything is hidden away behind the scenes and your template can
concentrate on making the data look pretty. Manipulating this kind of
data in Perl will be a lot easier than trying to do it in TT.
The TT Table plugin might be a good place to start from. It work in a
similar vein to the examples above, taking a list of items as a constructor
argument and providing rows() and cols() methods to selectively return
part of the list.
HTH
A
_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates