[Catalyst] Picking template type based on input

Alexander Hartmaier alexander.hartmaier at t-systems.at
Tue Mar 30 09:27:32 GMT 2010


Sounds like you want Catalyst::Action::Serialize.

--
Best regards, Alex


Am Freitag, den 26.03.2010, 10:43 +0100 schrieb Jon mailinglists:
> 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
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/


*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
T-Systems Austria GesmbH   Rennweg 97-99, 1030 Wien
Handelsgericht Wien, FN 79340b
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
Notice: This e-mail contains information that is confidential and may be privileged.
If you are not the intended recipient, please notify the sender and then
delete this e-mail immediately.
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*



More information about the Catalyst mailing list