What conventions or frameworks exist for MVVM in Perl?
Posted
by
Will Sheppard
on Programmers
See other posts from Programmers
or by Will Sheppard
Published on 2012-03-23T16:56:42Z
Indexed on
2012/03/23
17:39 UTC
Read the original article
Hit count: 286
We're using Catalyst to render lots of webforms in what will become a large application. I don't like the way all the form data is confusingly into a big hash in the Controller, before being passed to the template. It seems jumbled up and messy for the template. I'm sure there are real disadvantages that I haven't described properly... Are there?
One solution is to just decide on a convention for the hash, e.g.:
{
defaults => {
type => ['a', 'b', 'c']
},
input => {
type => 'a'
},
output => {
message => "2 widgets found of type a",
widgets => [ 'foo', 'bar' ]
}
}
Another way is to store the page/form data as attributes in a class (a ViewModel?), and pass a whole object to the template, which it could use like this:
<p class="message">[% model.message %]<p>
[% FOREACH widget IN model.widgets %]
Which way is more flexible for large applications?
Are there any other solutions or existing Catalyst-compatible frameworks?
© Programmers or respective owner