Catalyst Improving your Catalyst Application #13

Chained

package KitiWiki::Controller::Wiki;
use strict;
use warnings;
use base 'Catalyst::Controller';

sub wiki : Chained('/') PathPart('wiki') CaptureArgs(1) {
    my ($self, $c, $page_name) = @_;
    $c->log->debug("Acting on wiki page $page_name");
    $c->stash->{page_name} = $page_name;
    $c->stash->{page}      = $c->model('Wiki')->page($page_name);
}

sub latest : Chained('wiki') PathPart Args(0) {
    my ($self, $c) = @_;
    $c->stash->{revision}  = $c->stash->{page}->latest;
    $c->stash->{formatted} = $self->format_revision($c);
    $c->stash->{template}  = 'view_wiki.tt';
}
Infinity Interactive