[Catalyst] question from tutorial - does creating HTML in a controller using HTML::Widget violate MVC?

John Siracusa siracusa at mindspring.com
Wed Dec 6 02:06:50 GMT 2006


On 12/5/06 8:51 PM, Nilson Santos Figueiredo Junior wrote:
> On 12/5/06, John Siracusa <siracusa at mindspring.com> wrote:
>> What would this "Perl code layer" be responsible for doing?  Can you give
>> some examples?
>> 
> The most obvious example is data set sorting. The sort order is something
> presentation related and, thus, shouldn't be in your controller (at least from
> my POV).

I'd say that's borderline.  It could be viewed as "arranging the data" but
it could also be viewed as an inherent property of the data, e.g., in the
case of a top ten list.  (And practically speaking, it's usually much more
efficient to let the database do the sorting.)  Can you give another
example?

My stance has always been that I don't mind "code" in templates so long as
the sole purpose of that code is to layout and format the data.  IOW, a view
should never retrieve, create, or modify data.  It should just move around
and format what it's been given.

Now I suppose I could limit myself to a simple subset of a templating
language and then push off all the "code" parts of the view to a Perl
module, but I'm still not sure what that'd buy me, which is why I'm asking
for examples.

> I believe that the real benefit would be not being restrained to what TT can
> and cannot do while reaping the benefits of using templates.

I think they call that "Mason" ;)

-John





More information about the Catalyst mailing list