Re: [Templates] Design question

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

From: Perrin Harkins
Subject: Re: [Templates] Design question
Date: 21:25 on 28 Jun 2004
On Mon, 2004-06-28 at 14:58, Buddy Burden wrote:
> 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.

Actually, a tied hash is not an object.  Maybe you're passing something
else?

I'm not sure about the XS Stash, but the Perl Stash should do the right
thing on tied hashes and arrays, because they return "HASH" or "ARRAY"
in response to ref(), unlike objects.  For demonstration:

use Tie::Hash;

my %hash;
my $obj = tie %hash, 'Tie::StdHash';

my $hash = \%hash;
print "ref: " . (ref $hash) . "\n";
print "ref: " . (ref $obj)  . "\n";

- Perrin



_______________________________________________
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