[Catalyst] Plugin methods and context namespace
Sebastian Riedel
sri at oook.de
Fri Nov 25 01:19:43 CET 2005
Am 24.11.2005 um 23:36 schrieb John Wang:
> To keep the $c context namespace cleaner, I'd like to add plugin
> methods like $c->myplugin->foo instead of $c->foo.
>
> I have this working by creating a package MyPlugin and a plugin
> wrapper Catalyst::Plugin::MyPlugin. The wrapper just does a few
> things:
>
> inherits from Class::Data::Inheritable
> uses MyPlugin
> adds 'myplugin' to classdata
> sets $c->myplugin( MyPlugin->new( $c ) ) in prepare
>
> This works, but having an external MyPlugin.pm doesn't seem very
> clean. Is there a better way to get plugin methods in the $c-
> >myplugin->foo format?
MyApp->plugin( 'prototype', 'HTML::Prototype' );
$c->prototype->define_javascript_functions;
--
sebastian
More information about the Catalyst
mailing list