Eden Cardim wrote:
On Tue, Aug 11, 2009 at 2:15 PM, Matt Whipple<[email protected]> 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?
I considered using a chain, but figured sticking to my initial idea
offers a more self-contained, flexible solution which potentially frees
the controller actions to focus more on distinct processing and less on
any indistinctly retrieved result destination. Perhaps a more simple
expression of what I'm looking to do is to override the TT View default
of going to a template named according to the action to one named
according to the path (with a little extra DWIMmery). Consider, for
example, an application for which you may want to use customized
templates for certain edge cases in an application. Rather than having
to touch the code at all, the template could be dropped in place in the
right path by a designer and automatically used by the application. For
now I'm going to try it and see if it's useful, counter-productive, or
somewhere in the middle and then either release it for consumption or
bury it and disavow any responsibility for its creation.
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/