It seems that TT can't access keys in tied hashes. A little example is
provided using Apache::Session::File. Bug, feature, or did I overlook
something?

Hans


------------ example.pl -------------------------------------
#!/usr/bin/perl -w

use strict;
use Template;
use Data::Dumper;
use Apache::Session::File;

my $session = {};
my $stash   = {};

tie %{$session}, 'Apache::Session::File', undef, {
        Directory     => '/tmp',
        LockDirectory => '/tmp',
};

$session->{name} = "Hans";
$stash->{name}   = "Hans";

print "Toolkit version: $Template::VERSION\n";
print "Session: ", Dumper $session;
print "Stash:   ", Dumper $stash;
print "\n--- Template Output ---\n";
my $tproc = Template->new();
$tproc->process(\*DATA, {
        session => $session,
        stash   => $stash,
}) || die $tproc->error;

__DATA__
[% session.name || "No Name in Session" %]
[% stash.name   || "No Name in Stash" %]


prints:
-------------------------------------------------------------
Toolkit version: 2.05
Session: $VAR1 = {
          'name' => 'Hans',
          '_session_id' => '60fb8428d9d6af4c9bb8da0853f84752'
        };
Stash:   $VAR1 = {
          'name' => 'Hans'
        };

--- Template Output ---
No Name in Session
Hans



Reply via email to