On 6/29/06, Brandon Black <[EMAIL PROTECTED]> wrote: > If you find yourself putting code in your View templates that isn't > directly related to rendering this specific flavour of output, it > probably needs to be moved to the Controller. Good code in views: > iterating an arrayref to generate a <ul> list, walking a data > structure to generate a <table>, or walking a data structure to > generate a graph image.
I've found myself building somewhat "fat" views lately. Mostly, I've done it when trying to build generic "widget" thingies that might appear in different pages. By "fat" I mean resultset-manipulating views, but usually the manipulations are restricted only to the view-related aspect of them, though. This means stuff like ordering the resultset by some column (using order_by). I'm usually in doubt if this is indeed a good practice or if it should be done another way, but it sure makes things easier. Overall, I find it somewhat difficult to satisfactorily come up with a nice and clean design for generic widgets. For example, if you've got a login box that displays either login fields when the user is not logged in or some user information whe the user's logged in, you'll usually need some of HTML and some of Perl code. But it's really up to the view to decide whether it wants to display that widget or not, so the general controller actions should be widget agnostic. My main dilemma is: should I have a LoginBox controller that handles it and then forward from the view back to the controller while rendering (maybe issuing a subrequest?) or is it alright to have this sort of widgets with lots of code, possibly calling the model directly themselves? Is there an estabilished best practice for doing this? This is currently my main philosophical issue while developing using Catalyst. If someone could enlighten me regarding this subject, I'd appreciate it. ;-) -Nilson Santos F. Jr. _______________________________________________ List: [email protected] Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[email protected]/ Dev site: http://dev.catalyst.perl.org/
