-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

* Bernard Golden <bgolden at pacbell.net> [2003-06-25 18:19]:
> I wish to create a table with the year on the left, and the counts for
> each of the subsequent years strung out to the right of that year.  I
> can't quite figure out how to handle anonymous hashes in templates, so
> I was hoping someone could give me a pointer, or a code fragment in
> which they did something similar.  Alternatively, if it would be
> better to create a different form of data structure, I could do that,
> but I'm sure there must be a way to accomplish what I want to do.

Using the data you provided, something like this:

  [% FOREACH datum = data %]
    [% years = datum.values.0.keys.sort;
        datum.keys.0 %] - [%
        FOREACH year = years;
            year %] - [%
        END %]
  [% END %]

will create a table like:

   1991 => 1992 - 1998 - 2000 - 2002 -

   1992 => 1993 - 1994 - 1996 - 1998 - 1999 - 2000 - 2001 - 2002 - 2003 -

   1993 => 1993 - 1994 - 1995 - 1996 - 1997 - 1998 - 1999 - 2000 - 2001 - 2002 - 2003 
- 2004 - 2005 -

Keeping the loop from adding the " - " on the end is left as an
exercise, as is an explanation of what the loops do (sorry, I have to
catch a train!).

(darren)

- -- 
Tell a man that there are 400 Billion stars and he'll believe you.
Tell him that a bench has wet paint and he has to touch it.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE++iYFzsinjrVhZaoRAq58AKCg8WNke/SJhqjbDh5UuNzAUraBbgCgpPwp
ScPmUuj1IouCeaCcqHvKHnI=
=TmGP
-----END PGP SIGNATURE-----

_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to