[Catalyst] Loading template according to request path

J. Shirley jshirley at gmail.com
Tue Aug 11 23:11:30 GMT 2009


On Tue, Aug 11, 2009 at 2:47 PM, Eden Cardim <edencardim at gmail.com> wrote:

> 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 determin=
es
> > 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 overridi=
ng
> > 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) =3D @_;
>    $c->stash->{data} =3D $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->bo=
dy
> sub graph : Chained('content') Args(0) {
>    my($self, $c) =3D @_;
>    $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?
>
>
The fact that Chained doesn't render template from PathPart, but from the
action name? :)

It would be content/html.tt -- not content/as/html.tt

-J
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20090811/67e93=
7d6/attachment.htm


More information about the Catalyst mailing list