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

Eden Cardim edencardim at gmail.com
Wed Dec 6 16:04:09 GMT 2006

On 12/5/06, Nilson Santos Figueiredo Junior <acid06 at gmail.com> wrote:
> IMO, the real thing that's missing is Perl code layer between the
> controller and the template, i.e., the view should be composed by code
> + templates. If you don't do it this way you need to either a) put
> code which belongs to the view inside your controller, b) write large
> amounts of code in your templates using and reap *all* the great
> benefits that come along with large chunks of code written in TT
> language or c) write a TT plugin.
> "a" is fundamentally wrong, "b" will give you nightmares, "c" is
> arguably clumsy and not practical at all.
> Actually, someone could come up with a view class which would first
> call some Perl code and then process the TT template.

Why not override MyApp::View::MyView->process() and put your Perl code
layer in there? What I do is have ->process() build up pieces of HTML,
like tables, forms, etc, with whatever external module I see fit,
based on the stash data. Then I stuff them back into the stash and use
the template only for layouting those pre-built pieces.

Eden Cardim
Instituto Baiano de Biotecnologia
Núcleo de Biologia Computacional e Gestão de Informações Biotecnológicas
Laboratório de Bioinformática
"you seem to think that 'close enough' is close enough...
please learn to be 'literal' around programming."
merlyn - on irc.freenode.net#perl

More information about the Catalyst mailing list