I found a bug in how the Stash handles private variables, when accessed with the .item vmethod:
$ tpage
[% foo = { _private = 1 public = 2 } %]
foo.public: [% foo.public %]
foo._private: [% foo._private %]
foo.item('_private'): [% foo.item('_private') %]
There's a one-line fix for it (attached), but is it actually a bug in
Template::Stash, or in the docs (and my assumptions)?
(darren)
--
For every problem, there is a solution that is simple, elegant,
logical, and wrong.
-- H. L. Mencken
--- Stash.pm.orig Thu Jun 19 00:04:03 2003
+++ Stash.pm Thu Jun 19 00:04:24 2003
@@ -115,6 +115,7 @@
$HASH_OPS = {
'item' => sub { my ($hash, $item) = @_;
$item = '' unless defined $item;
+ return if $item =~ /^[_.]/;
$hash->{ $item };
},
'hash' => sub { $_[0] },
pgp00000.pgp
Description: PGP signature
