Re: protecting access to object instance fields?
Roger <[email protected]> Tue, 12 Feb 2013 14:20:52 +0800
| Newsgroups | gmane.comp.lang.perl.modules.template-toolkit |
|---|---|
| Message-ID | <[email protected]> |
E R <[email protected]> wrote: >When I have an object (e.g. blessed hash) in the stash, I'd like to prevent >TT from accessing any of the hash fields directly. It can still access the >method functions. > >A simple example - suppose the TT template looks like: > > [% obj.the_time %] > [% obj._unix_time %] > >and in the stash 'obj' is a blessed hash: > >package foo; > >sub new { bless { _unix_time => time }, shift } >sub the_time { ... } > >I'd like the first GET to succeed and the second one to either fail, raise >and exception, return the empty string or something like that. > >Is this possible? > >_______________________________________________ >templates mailing list >[email protected] >http://mail.template-toolkit.org/mailman/listinfo/templates