Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

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 [% Catalyst.stash.foo %]

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


Comment on Re: Accessing the stash within a TT file
Select or Download Code
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.
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 (Canon) 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.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2014-12-28 10:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (180 votes), past polls