[Templates] Design question

[prev] [thread] [next] [Date index for 2004/06/28]

From: Buddy Burden
Subject: [Templates] Design question
Date: 18:58 on 28 Jun 2004
Guys,

Okay, I've been using TT2 for a while now, and I'm really starting to 
get into it.  It's quite a lot better than any other templating tool 
I've used.  I even got the badger book. :-)

Now I have a design question.  I have an object, which acts (FTMP) like 
a Perl pseudohash.  Specifically, you can use it like a hashref, or like 
an arrayref.  I use it for storing rows I get back from the database. 
Consequently, I have lots of arrays of these lying around, which I 
naturally want to get into templates.

My first attempt was just to toss an array into the $vars I send to TT2. 
  This didn't work, of course, because even though you can _use_ it like 
a hashref, it _isn't_ a hashref.  It's an object.  So TT2 wanted to use 
my column names as methods.  After some thought, I decided to solve this 
by using AUTOLOAD to make any method that matched a column name return 
the data.  It's an imperfect solution, but it works.

The next problem I ran into was of the same sort.  I keep thinking of 
these things (the name of the object is "DataRow", BTW) as a hashref, 
even though I know better ... so I inevitably tried to use the "keys" 
virtual method on one.  Didn't work, because DataRow doesn't have a 
keys() method.  So I made one.

So, now things are working pretty much okay, but I'm worried that I've 
started down a dangerous path.  I'm thinking that I'm going to end up 
implementing all of the virtual functions of hashes (and maybe even 
arrays) that TT2 already has built-in all over again.  Reinventing not 
just one wheel here ...

So I'm wondering if anyone else has another possible solution.  Is there 
another direction I should try that I haven't thought of yet?  Or is my 
present course really the best way?

TIA for any thoughts and help.


		-- Buddy

_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates

(message missing)

[Templates] Design question
Buddy Burden 18:58 on 28 Jun 2004

Re: [Templates] Design question
Jeff Anderson 19:16 on 28 Jun 2004

Re: [Templates] Design question
Mark Mills 19:16 on 28 Jun 2004

Re: [Templates] Design question
Buddy Burden 20:20 on 28 Jun 2004

RE: [Templates] Design question
Bruce McKenzie 20:46 on 28 Jun 2004

Re: [Templates] Design question
Ken.Olstad 20:55 on 28 Jun 2004

Re: [Templates] Design question
Perrin Harkins 21:25 on 28 Jun 2004

Re: [Templates] Design question
Jeff Anderson 21:47 on 28 Jun 2004

Re: [Templates] Design question
Buddy Burden 16:11 on 01 Jul 2004

Re: [Templates] Design question
Jeff Anderson 18:05 on 01 Jul 2004

Re: [Templates] Design question
Buddy Burden 22:33 on 28 Jun 2004

Re: [Templates] Design question
Perrin Harkins 22:52 on 28 Jun 2004

Re: [Templates] Design question
Buddy Burden 23:18 on 28 Jun 2004

Re: [Templates] Design question
Perrin Harkins 03:21 on 29 Jun 2004

Re: [Templates] Design question
Buddy Burden 16:22 on 29 Jun 2004

Re: [Templates] Design question
Mark Mills 17:09 on 29 Jun 2004

Re: [Templates] Design question
Buddy Burden 17:47 on 29 Jun 2004

[Templates] Design question
Chris Ochs 06:53 on 08 Dec 2004

Generated at 08:55 on 15 Mar 2005 by mariachi v0.52