[Catalyst] Often used templates as method
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 ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Often used templates as method
well, if you make the structure of your templates mirror that of your controllers and actions, and use the end action that is shown in the tutorial, you don't have to define the template per action - the request gets automatically routed to the one with the same name as the action. On 8/13/07, Sven Eppler [EMAIL PROTECTED] wrote: 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 ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/ -- Daniel McBrearty email : danielmcbrearty at gmail.com http://www.engoi.com http://danmcb.vox.com http://danmcb.blogger.com find me on linkedin and facebook BTW : 0873928131 ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Often used templates as method
On Mon, Aug 13, 2007 at 01:50:54PM +0200, Sven Eppler wrote: 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: Why not just wrap these up into a controller method? $c-forward('/setup_error', [ $title, $message ]); or whatever? -- Matt S Trout Need help with your Catalyst or DBIx::Class project? Technical DirectorWant a managed development or deployment platform? Shadowcat Systems Ltd. Contact mst (at) shadowcatsystems.co.uk for a quote http://chainsawblues.vox.com/http://www.shadowcat.co.uk/ ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/