[Templates] Template::Stash bug, or "feature"?

darren chamberlain dlc@users.sourceforge.net
Thu, 19 Jun 2003 00:06:31 -0400


--DKU6Jbt7q3WqK7+M
Content-Type: multipart/mixed; boundary="Nq2Wo0NMKNjxTN9z"
Content-Disposition: inline


--Nq2Wo0NMKNjxTN9z
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

I found a bug in how the Stash handles private variables, when
accessed with the .item vmethod:

  $ tpage
  [% foo =3D { _private =3D 1 public =3D 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)

--=20
For every problem, there is a solution that is simple, elegant,
logical, and wrong.
    -- H. L. Mencken

--Nq2Wo0NMKNjxTN9z
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="Stash.diff"
Content-Transfer-Encoding: quoted-printable

--- 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 =3D {
     'item'   =3D> sub { my ($hash, $item) =3D @_;=20
                       $item =3D '' unless defined $item;
+                      return if $item =3D~ /^[_.]/;
                       $hash->{ $item };
                   },
     'hash'   =3D> sub { $_[0] },

--Nq2Wo0NMKNjxTN9z--

--DKU6Jbt7q3WqK7+M
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE+8TbHzsinjrVhZaoRAkpSAJ48oDmv9j6vnEDu3MpuVJA8SHJVjACdHQIc
pnIoI5dxRP2RKoJxXXvaw/A=
=z80d
-----END PGP SIGNATURE-----

--DKU6Jbt7q3WqK7+M--