[Catalyst] Picking template type based on input

Jon mailinglists jon.mlist at gmail.com
Fri Mar 26 20:55:50 GMT 2010

On Fri, Mar 26, 2010 at 6:03 PM, J. Shirley <jshirley at gmail.com> wrote:
> On Fri, Mar 26, 2010 at 9:31 AM, Jon mailinglists <jon.mlist at gmail.com> wrote:
>> On Fri, Mar 26, 2010 at 1:50 PM, Tomas Doran <bobtfish at bobtfish.net> wrote:
>>> Jon mailinglists wrote:
>>>> Hi all,
>>>> [snip]
>>> How is generating JSON in template toolkit not 100% insane?
>>> Please use something like Catalyst::View::JSON instead?
>> To be honest I haven't tried it but seeing you're involved in it I
>> understand that stance :)
>> I don't think Catalyst::View::JSON would help me though since I need
>> to send "YUI JSON", ie:
>> MyNamespace.callback({"ResultSet":{
> That's not "YUI JSON", that's just a JSON callback which
> Catalyst::View::JSON supports just fine (see the CONFIG section of the
> Catalyst::View::JSON docs).

I read a bit more about it just after sending the mail, it does indeed
seem to do what I want.

>> Which would force me to do make changes in the result anyway, and a
>> few loops in a tt2 file isn't that much of a problem.
> I use JSON callbacks frequently, with YUI, and find that decorating
> the resulting hash with pagination and then using
> DBIx::Class::ResultClass::HashRefInflator everything works remarkably
> well, without any munging.

Great, thanks for the tip. I'll look into that.

A bit OT but:
Is there any built in XSS protection built in some module in Catalyst?
I was thinking something like auth tokens one can add to the html only
known by the server and the loaded page, to protect private data sent
by JSON. Or isn't that secure enough?

More information about the Catalyst mailing list