On 04/23/2008 09:45 AM, Rajeev Cyrus wrote:
> Greetings.
>
> One of my TT pages required some massaging of data that I decided to do
> via referencing a subroutine in a template variable, eg:
> $c->stash->{mk_hash} = \&mk_hash;
>
> I would like to use this stashed variable on all of my templates so my
> question is:
> Where is the best place to initialize and set this variable? Where
> should i declare the mk_hash method? Is there some way I can configure
> catalyst to set certain template variables when the application starts?
I do that in MyApp::View::TT, as in this example:
http://search.cpan.org/src/KARMAN/Catalyst-Controller-Rose-0.04/t/examples/CatRose/lib/CatRose/View/TT.pm
I like to add virtual methods so that I can call them more easily. I prefer:
[% mything.dump_data %]
to:
[% USE Dumper; Dumper.dump_html( mything ); %]
Of course, you have to be careful when adding virtual methods, that you don't
step on the
default ones. So I just have a couple I often use (dump_data and as_json).
--
Peter Karman . [EMAIL PROTECTED] . http://peknet.com/
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/