Catalyst::Controller::View - Catalyst Controller that directly delegates to View


Catalyst-Contoller-View documentation Contained in the Catalyst-Contoller-View distribution.

Index


Code Index:

NAME

Top

Catalyst::Controller::View - Catalyst Controller that directly delegates to View

SYNOPSIS

Top

    package MyApp::Controller::View;
    use strict;
    use warnings;
    use base 'Catalyst::Controller::View';

DESCRIPTION

Top

A Catalyst Controller that delegates to View class directly, for convienent purpose.

METHODS

Top

default

The default action. It sets $c-stash->{template}> to the path given by the URI unless there is no such file under root directory.

For instance, suppose your MyApp::Controller::View class is a subclass of Catalyst::Controller::View, when the incoming path is /view/foo/bar.html, then $c-stash->{template}> has the value /view/foo/bar.html if the file root/view/foo/bar.html exists.

AUTHOR

Top

Liu Kang-min <gugod@gugod.org>

LICENSE

Top

This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself.


Catalyst-Contoller-View documentation Contained in the Catalyst-Contoller-View distribution.
package Catalyst::Controller::View;

use strict;
use warnings;
use base 'Catalyst::Controller';

our $VERSION = 0.01;

sub default : Private {
   my ( $self, $c ) = @_;
   my $f = $c->path_to('root', @{$c->req->args});
   $c->stash->{template} = $f->relative($c->path_to('root')) .""
       if -f "$f";
}

1;