[Catalyst] Picking template type based on input
    Jon mailinglists 
    jon.mlist at gmail.com
       
    Fri Mar 26 09:43:29 GMT 2010
    
    
  
Hi all,
I'm making a small catalyst application and I want to be able to serve
different types of content based on parameters and/or request headers.
I'm curious about where the "correct" location for that kind of code
is, my current sollution is in the Root end like this:
sub end : ActionClass('RenderView') {
...
if ($c->stash->{json} || $c->request->params->{json} ||
$c->req->header('accept') =~ /json/)
{
   $c->stash->{template} = $c->action.'_json.tt';
   $c->res->headers->content_type( 'Application/json; charset=utf-8' );
}
...
}
but it feels "wrong" to put it in the Root controller rather than the
view.  Is this really the place where I'm supposed to have that kind
of logic? Would that also be the place if I want to add pdf out to
pick another View to forward to?
Thanks in advance
Jon
    
    
More information about the Catalyst
mailing list