Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Accessing the stash within a TT file

by ikegami (Pope)
on Jun 30, 2009 at 15:45 UTC ( #776070=note: print w/replies, xml ) Need Help??

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 [% %]

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 (Bishop) 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-

    [% %] == [% 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-

    [% %] == [% 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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://776070]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2020-02-22 10:53 GMT
Find Nodes?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?

    Results (99 votes). Check out past polls.