[Templates] property vs method?
Rodney Broom
rbroom+tt2 at rbroom.com
Wed Mar 5 18:39:04 GMT 2008
>From perltoot:
<snippet>
An object is nothing but a way of tucking away complex behaviours into a neat little easy-to-use bundle. [...] Users (well, programmers) can play with this little bundle all they want, but they aren't to open it up and mess with the insides. Just like an expensive piece of hardware, the contract says that you void the warranty if you muck with the cover. So don't do that.
</snippet>
To be helpful, maybe this:
[% obj.hash.name %]
That's off the cuff, I haven't tried.
Long term (or short if you have the time), I suggest doing it Tom's way and making a method for those properties. For a shortcut, you might add a property() method:
[% obj.property('name') %]
---
Rodney Broom
----- Original Message -----
From: "Chris Petersen" <lists at forevermore.net>
To: <templates at template-toolkit.org>
Sent: Tuesday, March 04, 2008 23:53
Subject: [Templates] property vs method?
>I have an object that I'm passing into TT. It happens to have
> properties and methods that share the same name. It looks by default
> that if I just use [% obj.name %] it calls $obj->name() rather than
> printing $obj->{name}, so I'm wondering if there's a clear way to
> force TT to use one or the other.
>
> -Chris
>
> _______________________________________________
> templates mailing list
> templates at template-toolkit.org
> http://mail.template-toolkit.org/mailman/listinfo/templates
>
More information about the templates
mailing list