Create Custom Controller Attributes

Many base controllers like Catalyst::Controller::HTML::FormFu make use of those nifty attributes.

sub form : Form { ... }

This action will automatically load a config file and puts a HTML::FormFu object in the stash.

Add this piece of code to your controller

sub _parse_NSPathPart_attr {
    my ( $self ) = @_;
    return ( PathPart => $self->action_namespace() );
}

This will add a NSPathPart attribute to your controller.

Usage:

package MyApp::Controller::User;

sub object : Chained('/') NSPathPart CaptureArgs(1) { }

This action is now reachable by the name of the controller e. g. /user.

My tags:
 
Popular tags:
 
Powered by Catalyst
Powered by MojoMojo Hosted by Shadowcat - Managed by Nordaaker