[Catalyst] Debugging Catalyst with Eclipse

Nathan Waddell arafeandur at gmail.com
Wed Jan 23 16:49:03 GMT 2008


I'm signing up for the wiki as I write this. If that is the direction
the documentation effort is going, I'm going to concentrate on it. My
employer allows me to dedicate some of my time each week to 'creative
projects unrelated to our core business' and is a big consumer of Open
Source and Free Software - so they support my giving back to OSS/FS.

I will definitely comb the mailing list archives to see what I can
come up with that can be fleshed out in documentation. However, I'm
keen to avoid deprecated code, so I may ask if things are still valid
or if my understanding of them is complete before I post docs.

One thing that I can't seem to find (and maybe I don't know where to
look) is an intermediate overview of how to use the stash in
coordination with templating systems. For example, I know that I can:

Example TT template:
<h1>A very basic template.</h1>
<p>Here's the variable you passed to this page: [% foo %]

Example catalyst snippet:
my $foo = "bar";
$c->stash->{'foo'} = $foo;

So the resulting template will print the following html:
<h1>A very basic template.</h1>
<p>Here's the variable you passed to this page: bar</p>

However, the template toolkit also allows for hashes to be passed to it, like:
my $foo = ( bar => 'Foobar');

Which can then be accessed as [% foo.bar %] - if I'm understanding it correctly.

How do you pass this hash to catalyst? By deriving a reference?

i.e.
my $foo_ref = \%foo;
$c->stash->{'foo'}= $foo_ref;

If this is so, do you have to worry about dereferencing {foo} if you
need to check its value in the stash with another Catalyst controller?

i.e.
my $foobar_ref = $c->stash->{'foo'};
my $foobar = %{$foobar_ref};

Nathan



More information about the Catalyst mailing list