[Catalyst] Catalyst 5 preview!

Michael Reece mreece at sacbee.com
Thu Mar 31 20:52:19 CEST 2005


>    sub html : Regex('^(\w+).html$') {
>        my ( $self, $c ) = @_;
>        $c->res->output('Hello');
>    }

Can those patterns be expressions, such as:

    my $table_re = qr/^(my|list|of|tables)$/;

    sub table : Regex($table_re) { ... }

?


On 3/30/05 2:47 PM, "Sebastian Riedel" <sri at oook.de> wrote:

> I previously mentioned that we are heavily working on Catalyst 5, now i
> want to give you a chance to comment on the most visible changes. (in
> case you're not on #catalyst)
> 
> With Catalyst 4 actions are defined like this:
> 
>    package MyApp::C::Foo;
> 
>    MyApp->action(
> 
>        'foo' => sub {
>            my ( $self, $c ) = @_;
>            $c->res->output('Hello');
>        },
> 
>        '?bar' => sub {
>            my ( $self, $c ) = @_;
>            $c->res->output('Hello');
>        },
> 
>        'lalala/foo/bar' => sub {
>            my ( $self, $c ) = @_;
>            $c->res->output('Hello');
>        },
> 
>        '/^(\w+).html$/' => sub {
>            my ( $self, $c ) = @_;
>            $c->res->output('Hello');
>        },
> 
>        '!end' => sub {
>            my ( $self, $c ) = @_;
>            $c->res->output( $c->res->output . ' Catalyst!' );
>        },
> 
>    );
> 
> In Catalyst 5 it would look like this:
> 
>    package MyApp::C::Foo;
> 
>    sub foo : Global {
>        my ( $self, $c ) = @_;
>        $c->res->output('Hello');
>    }
> 
>    sub bar : Local {
>        my ( $self, $c ) = @_;
>        $c->res->output('Hello');
>    }
> 
>    sub lalala : Path('/lalala/foo/bar') {
>        my ( $self, $c ) = @_;
>        $c->res->output('Hello');
>    }
> 
>    sub html : Regex('^(\w+).html$') {
>        my ( $self, $c ) = @_;
>        $c->res->output('Hello');
>    }
> 
>    sub end : Private {
>        my ( $self, $c ) = @_;
>        $c->res->output( $c->res->output . ' Catalyst!' );
>    }
> 
> And NO! those method names for regex and path actions are not useless,
> because now internally all actiones get a unique private address for
> forwarding, in our example:
> 
> /foo/foo
> /foo/bar
> /foo/lalala
> /foo/html
> /foo/end
> 
> And you can even inherit actions, say hello reusable components! :)
> 
>    package My::Reusable::Component;
> 
>    sub index : Local {
>        my ( $self, $c ) = @_;
>        $c->res->output('Hello');
>    }
> 
>    package MyApp::C::Foo;
> 
>    use base 'My::Reusable::Component';
> 
> Have fun!
> 
> --
> sebastian
> 
> 
> _______________________________________________
> Catalyst mailing list
> Catalyst at lists.rawmode.org
> http://lists.rawmode.org/mailman/listinfo/catalyst
> 

-- 
michael reece :: web engineer :: mreece at sacbee.com :: (916)321-1249





More information about the Catalyst mailing list