[Templates] differentiating hash entries / methods with same name

Andrew Strader astrader@ecnext.com
Wed, 8 Nov 2006 10:01:34 -0500


Generally no. TT will see [% obj %] as an instance of the pertinent
class, not as a hash reference.

You could make [% obj.item('foo') %] work simply by defining a method
called "item" for it.


-----Original Message-----
From: templates-admin@template-toolkit.org
[mailto:templates-admin@template-toolkit.org] On Behalf Of Josh
Rosenbaum
Sent: Tuesday, November 07, 2006 4:52 PM
To: Dami Laurent (PJ)
Cc: templates@template-toolkit.org
Subject: Re: [Templates] differentiating hash entries / methods with
same name

Dami Laurent (PJ) wrote:
> Hi all,
>=20
> Suppose an object $obj has both a hash entry $obj->{foo} and a method=20
> $obj->foo().
>=20
> If I pass this object to a template,  [% obj.foo %] performs a method
call.
>=20
>  Is there a way to access the hash entry instead?
>=20
> Thanks in advance, L. Dami
>=20

Does obj.item('foo') work?

-- Josh

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