http://www.perlmonks.org?node_id=776070


in reply to Accessing the stash within a TT file

I presume you are talking about Catalyst's stash. TT doesn't know anything about Catalyst. Fortunately, Catalyst::View::TT passes the Catalyst object to TT as a variable (under the name Catalyst by default). You should be able to do [% Catalyst.stash.foo %]

I'm just learning Catalyst now, so let me know if that doesn't work.

Replies are listed 'Best First'.
Re^2: Accessing the stash within a TT file
by perrin (Chancellor) on Jun 30, 2009 at 15:58 UTC
    "Stash" is actually a TT convention that Catalyst copied.
      Stash is actually a perl convention that TT copied :)
        Well, true, but using it as the name of the data to be passed to a templating engine seems like a convention that TT established, and that's the what Catalyst uses it for.
Re^2: Accessing the stash within a TT file
by Your Mother (Archbishop) on Jun 30, 2009 at 16:43 UTC

    Just to expand. The stash is exposed to the template at the top level (by default, in TT views, not necessarily in all views) so these are equivalent-

    [% Catalyst.stash.foo %] == [% foo %]

    And unless you're using the TT::Site view helper/generator or have modified your CATALYST_VAR yourself in your view configuration, then c will be the default Cat context/app object-

    [% c.stash.foo %] == [% foo %]

    I have mixed feelings about using Catalyst v c in the templates. It's nice to be explicit but at the same time it crowds template code and if one can get used to $r in modperl, c seems fine.

Re^2: Accessing the stash within a TT file
by Anonymous Monk on Jun 30, 2009 at 15:58 UTC
    Thanks for the response. Much appreciated.
    In this particular project, I'm not using Catalyst, just plain vanilla Template Toolkit. Would be very interested how access to the stash is accomplished under that scenario.
    I can take a look at the Catalyst s/c to see what they do. I'm curious about it being a circular ref.