[Catalyst] Loading template according to request path
Eden Cardim
edencardim at gmail.com
Tue Aug 11 21:47:56 GMT 2009
On Tue, Aug 11, 2009 at 2:15 PM, Matt Whipple<matt at mattwhipple.com> wrote:
> Thanks everyone for your input, I'm certainly gathering that there is
> nothing preexisting that does what I'm looking to do. I'll continue to
> clean up my version and throw it on CPAN if it seems appealing enough. As a
> quick overview the basic premise is a more direct link from the path to the
> template which would be used for those times when the URI path determines
> presentation after passing through a reusable action handler which tailors
> content (and doesn't necessarily have to worry about the template
> selection). This is presently done in the auto action so that overriding
> the behavior is natural and any extended logic can be handled when and where
> desired.
That's precisely what chained actions are for:
sub content : Chained('/') CaptureArgs(0) PathPart('content/as') {
my($self, $c) = @_;
$c->stash->{data} = $c->model('Content');
}
# /content/as/html -- renders root/content/as/html.tt
sub html : Chained('content') Args(0) {}
# /content/as/text -- renders root/content/as/text.tt
sub text : Chained('content') Args(0) {}
# /content/as/graph
# doesn't process a template at all as long as View::SVG sets $c->res->body
sub graph : Chained('content') Args(0) {
my($self, $c) = @_;
$c->forward('View::SVG'); # sets res->body, res->content_type, etc.
}
sub whatever : Chained('content') Args(0) { #etc... }
# insert jshirley's end action here
what's missing?
--
Eden Cardim Need help with your Catalyst or DBIx::Class project?
Code Monkey http://www.shadowcat.co.uk/catalyst/
Shadowcat Systems Ltd. Want a managed development or deployment platform?
http://edenc.vox.com/ http://www.shadowcat.co.uk/servers/
More information about the Catalyst
mailing list