[Catalyst] Often used templates as method

Sven Eppler sven at sveneppler.de
Mon Aug 13 12:50:54 GMT 2007


Hello!

I'm using catalyst with TT as my template engine. I made some templates  
for errors, warnings, messages, redirecting and stuff. But because i'm a  
quite a lazy boy i don't like to do this:


$c->stash->{title} = "Some Error Title";
$c->stash->{message} = "Some error message";
$c->stash->{template} = 'box/error';


over and over again. Beside my lazyness, this would even help me out if i  
deicide to rename the template sometime or stuff like this. So i thought  
about a better way. Which eventually should be a method which resides in  
the View itself. Something like:


$c->view('TT')->error('Some Error Title', 'Some error message');


But my first shot got me in some trouble: in the view i only get the  
reference of the view but not the catalyst context variable passed by. So  
i'm quite helpless how to proceed from there?

Maybe even my approach is totaly wrong, but then i would appreciate any  
suggestions in the right direction. :)


Thanks in advance,
Sven




More information about the Catalyst mailing list