On Tue, Aug 11, 2009 at 2:47 PM, Eden Cardim <[email protected]> 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? > > 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
_______________________________________________ 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/
