Catalystadventures in webdev with perl Don't Repeat YourselfDRY is a central principle in Catalyst, yet there is one piece of code that is identical in 90% of all Catalyst applications.
Basically, we want to render a template unless we already have a response, or are redirecting. Catalyst::Plugin::DefaultEnd to the rescue! So, rather than doing this again and again, I've made a plugin for you to use. sure, it's not much code, but at least it's one function less to worry about. Here's how to use it:
As an added bonus, you can now set dump_info=1 as a url parameter to force the end action to die, and display the debug info. Note that this is only provided in Debug mode. By default, DefaultEnd will forward to the first view it can find. If you have more than one view, you might want to specifiy the active one, by setting $c->config->{view}. If you need to add more things to your end action, you can extend it like this.
Have fun! -- marcus last updated 2 years ago # |